Suggested RegExp Improvements
wavded at gmail.com
Fri Nov 12 14:52:13 PST 2010
After considering all the breadth this discussion could take maybe it
would be wise to just focus on one issue at a time. For me, the biggest
missing feature is lookbehind. Its common to most languages
implementing the Perl-RegExp-syntax, it is very useful when looking for
patterns that follow or don't follow a particular pattern. I guess I'm
confused why lookahead made it in but not lookbehind. What do people
think about including this feature?
On Fri, 2010-11-12 at 16:20 -0600, Marc Harter wrote:
> I will start out with a disclaimer. I have not read both ECMAScript
> specifications for 3 and now 5, so I admit that I am not an expert in
> expert discussion over this topic as proposed enhancements to the
> RegExp engine for Harmony.
> I will start with a list of lacking features in JS as compared to Perl
> * No \A or \Z anchors to match the start or end of the string.
> Use a caret or dollar instead.
> * Lookbehind is not supported at all. Lookahead is fully
> * No atomic grouping or possessive quantifiers
> * No Unicode support, except for matching single characters with
> * No named capturing groups. Use numbered capturing groups
> * No mode modifiers to set matching options within the regular
> * No conditionals.
> * No regular expression comments. Describe your regular
> regular expression string.
> I don't know if all of these "need" to be in the language but there
> have been some that I have personally wanted to use:
> * Lookbehind! ECMAScript fully supports lookahead, why not
> lookbehind? Seems like a big hole to me.
> * Named capturing groups and comments (e.g.
> http://xregexp.com/syntax/). Mostly I argue for this because
> it makes RegExp matches more self-documenting. Regular
> Expressions are already cryptic as it is.
> I do like some of the new flags proposed in
> (http://xregexp.com/flags/) but personally haven't used them but maybe
> that is something also for discussion.
> Marc Harter
More information about the es-discuss