Hacker News new | ask | show | jobs
by draegtun 4493 days ago
You can write more verbose regex using Named Capture Buffers. Here is an example I posted on HN not long ago: https://news.ycombinator.com/item?id=6895126

NB. Follow link to original post to compare against standard regex version.

There are also some nice grammar parsers available in some languages which make this even easier. For examples of this see Perl6 Rules/Grammar, Perl5 Regexp::Grammars or (for something which doesn't used regex at all is) Rebol Parse.

For eg. Here is my Rebol version of the HN post above: http://www.reddit.com/r/programming/comments/1smpa1/why_rebo...

And here is a presentation which shows a great example using Perl6 grammars: http://jnthn.net/papers/2014-fosdem-perl6-today.pdf

Refs:

- http://en.wikibooks.org/wiki/Perl_6_Programming/Grammars

- http://en.wikipedia.org/wiki/Perl_6_rules

- https://metacpan.org/pod/Regexp::Grammars

- http://www.rebol.com/docs/core23/rebolcore-15.html

- http://blog.hostilefork.com/why-rebol-red-parse-cool/

PS. Alternatively f you looking for something interactive then checkout tools like these: http://rebol.informe.com/blog/2013/07/01/parse-aid/ | https://metacpan.org/pod/Regexp::Debugger