3 ms·
I don't know why I'd never previously considered regular expressions as being a compile/transpile target. It's pretty obvious from PL theory and makes a ton of
by echelon 4y ago
I don't know why I'd never previously considered regular expressions as being a compile/transpile target. It's pretty obvious from PL theory and makes a ton of sense.
That said, after looking at this syntax, I'm not sure that this is much of an improvement. Maybe I've spent far too much time in Regex land [1], but I know I'd perform much slower in this. It's not particularly beautiful, either. The verbosity doesn't seem clearer.
Variables and comments are great, though. We need to add them in future regexes.
Overall, good idea. I'd like to see more takes on this.
[1] https://jimbly.github.io/regex-crossword/ https://jimbly.github.io/regex-crossword/
- TuringTest 4y agoIt may be a good way to standardize regexp syntax for users of all levels of expertise. Every text editor, shell environment, programming language or desktop application seems to use regular expressions with a syntax which is slightly different to all the others, but not different enough to call it with a different name. This means that a newbie learning regular expressions will be thrown into an environment where it can learn the basic principles, but the rules it learns are not generalisable to all applications (e.g. do I match an arbitrary string with '*', or '.*' ? Can I reuse matched patterns with (1) or with {1}? Etc.) A new readable and easy-to-learn syntax that is nevertheless portable may work like markdown, as a simple-yet-universal new way to apply regexp that newcomers may learn with confidence and apply everywhere, replacing all the previous slightly incompatible versions.
- camtarn 4y agoMatching an arbitrary string with '*' is not a regular expression - it's a shell glob pattern. Different thing entirely. Maybe they should be the same thing, yes. And although I don't know for sure, reusing a matched pattern within the regex string using (1) seems like it would be very strange, because () are metacharacters for grouping.
- TuringTest 4y agoThey are valid patterns in MS Word and Notepad++ search and replace, though. (Word uses parentheses to create the group then \1 to reuse it in the replacement string, while Notepad uses $1). That's what I meant about every system using a different syntax for what's basically the same functionality.
- hnlmorg 4y agoI think that’s a fair summary. Interesting idea but the syntax adds nothing to the readability of regex. I’d be more impressed with this if it targeted multiple different regex targets, since not all implementations of regex are equal. But in its current state it has all the problems of regex plus now the problems of this new language on top. Looks a fun personal project though. Hope the developers enjoyed building it.
- jsnell 4y agoThose improvements are not really novel though. Perl regular expression have had variables, comments, non-significant whitespace basically forever.
- macintux 4y agoAfter learning Perl, nearly every language has been a disappointment when it comes to regexes and text handling in general. I couldn't believe it when Java was released with not only no regex capability in the language syntax, but no library either.
- dxbydt 4y agohttps://docs.oracle.com/javase/7/docs/api/java/util/regex/package-summary.html https://docs.oracle.com/javase/7/docs/api/java/util/regex/pa... pcre has always had java and scala support.
- zokier 4y agoJava Pattern != Pcre != Perl regex, they are all distinct implementations with own quirks
- macintux 4y agoDuring Sun’s initial Java 1.0 release roadshow I drove to Chicago to attend. At the time, java.util.regex didn’t exist. I don’t know how to identify when it appeared.
- Avshalom 4y agoSays at the bottom since 1.4 which would be 2002 according to wikipedia but the history of java version numbers seems weird and 1.4 might just be the last time the java.util.regex api changed.
- cutler 4y agoWorse, Java regexen still require metacharacters to be escaped despite the recent introduction of raw string literals. Would you include Ruby in your comparison given that it inherits its regex implementation largely from Perl despite Onigurama's slight differences?
- tmtvl 4y agoComments are a great idea, you're right! https://perldoc.perl.org/perlre#/x-and-/xx https://perldoc.perl.org/perlre#/x-and-/xx