6 ms·
> sadism would definitely be a new development I guess that might depend upon your regexps and how gnarly/undocumented they are :-)
by pstuart 7y ago
> sadism would definitely be a new development
I guess that might depend upon your regexps and how gnarly/undocumented they are :-)
- thyrsus 7y agoWas it not perl that introduced the documentation feature to regexp (the extended "x" flag)?
- raiph 7y agoI think Perl got it in 99 or 2000. The only other two possibilities are Ruby or PCRE. But I think they were following Perl rather than leading at that time. ---- Raku's reinvention of regexes threw away the x flag. Instead comments are always supported. And whitespace is insignificant. ---- Except when one explicitly asks for it to implicitly be significant. Imo this simple maneuver is shockingly sweet, the sort of thing I'm glad Larry Wall saw, with his usual piercing clarity, is brain-dead obviously precisely the right thing to do: rule declaration { <declarator> <name> '=' <value> } The above declares a `rule` which is like a regex except it doesn't backtrack between atoms, and, if there's whitespace between atoms, it treats that as a tokenizing boundary. So, for example, whitespace can appear in the input where it appears in the pattern, and tokens corresponding to the atoms (`declarator`, `<name>`, etc.) can't run into each other unless one is comprised of alphanumerics and the other non-alphanumerics. This is precisely how humans expect things to work; `let foo` must have a space between `let` and `foo`, but `let foo=42` is OK because `=` is a non-alphanumeric. Simple. Sweet.