Re:Best syntax for a regex literal
by vonox on Tuesday January 29, 2019 @02:12PM
(#19029023)
Thanks
[ Parent
| on HN ]
I also use an alternative regex syntax to improve readability. For example:
re ("abc" | ["0"-"9"]+)
means this:
/abc|[0-9]+/
(You can put whitespaceses into the literal)
PCRE have the /x modifier to allow whitespace and comments.
When reinventing the wheel, it's hard to top what other do already pretty well. Also, be warned people have to learn your syntax and this will probably stop them using it.