3 ms·
What would you propose as an alternative to regexes that provides the same functionality without the unreadable syntax? I wrote something like that in C# once
by Timwi 1y ago
What would you propose as an alternative to regexes that provides the same functionality without the unreadable syntax?
I wrote something like that in C# once [0] but I'm not getting the impression that there's a lot of demand for that kind of thing.
[0] https://github.com/Timwi/Generex https://github.com/Timwi/Generex
- fwip 1y agoChiming in - I've found the Pattern type in Unison[0] to be very nice to use. When you're just using the built-in patterns, it is similar to verbose regex. The real power of them is that it's easy to define, name, and re-use sub-patterns. I think it's similar to parser combinators in this way, like nom from rust[1]. [0] https://share.unison-lang.org/@unison/website/code/main/latest/types/@@Pattern https://share.unison-lang.org/@unison/website/code/main/late... [1] https://docs.rs/nom/latest/nom/ https://docs.rs/nom/latest/nom/
- girvo 1y agoParsing expression grammars (pegs) are usually IME more maintainable long term, partially just because of much more testable and composable they are
- IshKebab 1y agoThere's a whole list of alternative syntaxes here: https://github.com/oils-for-unix/oils/wiki/Alternative-Regex-Syntax https://github.com/oils-for-unix/oils/wiki/Alternative-Regex... I haven't actually used them because generally the right alternative to a regex is a proper parser.