> Regarding "RegEx", I'm pretty certain Brendan was talking about a
> hypothetical new library (name unimportant) that the JavaScript community
> 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.

It is somewhat dormant now; I planned to port it to JavaScript (from
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.

Highlights:

- You can capture an entire (recursive) JSON structure with named and
repeated elements (a generalization of named capture).  JavaScript
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:
http://chubot.org/json-pattern/test-cases/testLs.html .

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.

Andy
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to