Proposal for exact matching and matching at a position in RegExp
andy at chubot.org
Thu Mar 4 00:40:50 PST 2010
> Regarding "RegEx", I'm pretty certain Brendan was talking about a
> might create in the future. I don't think anyone has suggested adding a
I worked on something like this:
http://code.google.com/p/json-pattern/ . It is more a rethinking of
regular expressions than just fixing existing bugs.
Python) but unfortunately haven't gotten around to it. The lack of
standard /y definitely blocks it. I guess I will have to just use the
proprietary /y extension for now.
My belief is that regular expressions are hobbled by their syntax. If
they didn't have such bad syntax (^ means either negation or the start
of a string; you sometimes negate with ^ and sometimes negate with
capitalization, the whole (? nightmare,etc. ), then people would write
large, useful and fast regexes and no one would bat an eye.
- You can capture an entire (recursive) JSON structure with named and
currently just allows you to capture individual numbered values.
- There are extensible filters (pipes) for converting values. You can
capture \d+ to the number 3 rather than the string "3"; you can write
a filter to convert "3-2-2009" to a Date() instance, etc.
- Pattern reuse / composition (nicer than Perl's)
- More readable and more consistent syntax (I wasn't completely happy
with where I ended up, but I have some unimplemented improvments)
Here is an example of a single expression that parses 'ls -al' output:
It's interesting that regular expression syntax in computers has been
evolving continuously for over 40 years now. It's probably older than
any language still in common use except perhaps FORTRAN.
More information about the es-discuss