logoalt Hacker News

galaxyLogictoday at 6:31 AM2 repliesview on HN

2 RegExp problems:

1. You can not compose a bigger regexp out of smaller ones

2. A regexp can not "call" other regexps


Replies

wwind123today at 6:44 AM

To do regex matching efficiently, you need to compile the pattern before using it. That'd exclude dynamically "calling" other regex patterns. But bigger regex pattern strings can be composed from smaller regex pattern strings. You'd just need to do the composition before the compilation.

show 1 reply
woadwarrior01today at 9:07 AM

Swift has a RegexBuilder[1][2] interface, in addition to the usual string-ey interface that allows composition.

[1]: https://github.com/swiftlang/swift-evolution/blob/main/propo...

[2]: https://developer.apple.com/documentation/regexbuilder