swiftlang / swiftlang/swift-experimental-string-processing

Inserting regex into literal regex expressions

Open
#821 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement swift-evolution-required
Dominant language
Swift
Stars
308
Forks
52
Avg merge
12h 45m
Merged PRs (30d)
2

Description

(From the forums topic https://forums.swift.org/t/inserting-regex-into-literal-regex-expressions/81070.)

When a regex has been declared e.g. via a literal expression:

let greeting = /(hello|hi)/

Then it can be nice to use this in another regex (this does work today):

let greetingSomeone = Regex {
    greeting
    ChoiceOf{ " "; ", " }
    OneOrMore { .word }
}

It should be possible to insert the greeting regex directly into a literal regex (the syntax might have to be different):

let greetingSomeone = /\(greeting)( |, )\w+/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the literal regex expression entry point and compare it with the existing RegexBuilder composition shown in the issue. Define the supported interpolation syntax and add coverage for embedding greeting in a literal; done when the example compiles and matches the intended greeting forms.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.