3 ms·
2 RegExp problems: 1. You can not compose a bigger regexp out of smaller ones 2. A regexp can not "call" other regexps
by galaxyLogic 4mo ago
2 RegExp problems:
1. You can not compose a bigger regexp out of smaller ones
2. A regexp can not "call" other regexps
- wwind123 4mo agoTo 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.
- ystlum 4mo agoAlso define blocks if all someone wants is to break the pattern up to make it more readable.
- galaxyLogic 3mo agoGreat idea
- galaxyLogic 4mo agoI'm just thinking in JavaScript I can do this: let s = "abc" + "def"; Why can't I do: let regExp = /abc/ + /def/; If JavaScript (or some other) interpreter can turn /abc/ into a RegExp, why can't it do the same for /abc/ + /def/ ?
- woadwarrior01 4mo agoSwift 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/proposals/0351-regex-builder.md https://github.com/swiftlang/swift-evolution/blob/main/propo... [2]: https://developer.apple.com/documentation/regexbuilder https://developer.apple.com/documentation/regexbuilder