4 ms·
When would something like this be necessary?
by love2read 4y ago
When would something like this be necessary?
- nyellin 4y agoEvery time you write a non trivial regex! Regexes often contain complex parts that repeat themselves throughout the regex or can be combined into higher level patterns. This adds support for that.
- chii 4y ago> Regexes often contain complex parts that repeat themselves throughout the regex or can be combined into higher level patterns. sounds like a parser use case.
- xdfgh1112 4y agoOne of the coolest things about Raku/Perl6 was how it made grammars a first-class citizen, like how Perl 5 made regexes a first-class citizen.
- asicsp 4y agoIf supported, you can use verbose flag and subexpression calls for such cases. From a cursory glance, I found only the numeric `range` support the standout feature I'd want in existing regex support.
- Diris 4y agoThat reminds me of that nice article about how to do that kind of thing in python [0] The unreasonable effectiveness of f-strings and re.verbose https://news.ycombinator.com/item?id=31457188 https://news.ycombinator.com/item?id=31457188
- bmn__ 4y agoYou make it sound as if regex don't have this ability, but they already do.
- eternityforest 4y agoLooks like it would be good if you had to use some ancient regex engine. Otherwise, I find regex is extremely easy, since the problems it solves well are very simple, and one can develop it interactively by trial and error, by looking at the highlights in their editor. I could possibly see actually using this if the playground had a similar "Try it on real text instantly" feature, but I've never had a problem with traditional regex+trial and error.
- SonOfLilit 4y agoGuessing you were downvoted because of the "ancient" part that has nothing to do with it. Also, many people don't agree with the "regex is fine" part.
- an1sotropy 4y agoyou may be resigned to trial and error being an essential part of regex development, but the reliance on trial and error should be (1) a signal that something can be improved with how programmers write regexs, and (2) a symptom of a programming ethos that essential things should be difficult. I'm glad that this project (and others like that others have highlighted here) allow us to improve on (1), and I am always encouraging my profession peers in computing to reconsider (2).
- SonOfLilit 4y agoThe answer is the same as that for more expressive languages with more ergonomic syntax and less footguns vs C.