Suggest adopting .NET/Perl regexp named capture syntax

Lars Hansen lhansen at
Wed Oct 24 12:20:00 PDT 2007

> -----Original Message-----
> From: es4-discuss-bounces at 
> [mailto:es4-discuss-bounces at] On Behalf Of StevenLevithan
> >> One other question... can the results from named capture be used in
> >> replacement closure function? I.e., will you be able to do
> >> like str.replace(/(?P<name>)/,function(match){return;});
> > 
> > The captured substrings with names are available as properties on
> > match result object, so that should work, yes.
> But the match result object is not available within a 
> replacement closure function, hence the question.

Sorry, brain fart on my part.  Interesting point.  Will look into it;
expect another ticket tomorrow.


> At least in 
> ES3, arguments[0] is a string primitive containing the entire 
> match (i.e. backreference zero). It could be changed to a 
> String object and have the named backreferences attached to 
> it as properties (which is how I handle the issue in my 
> XRegExp  library), 
> but this is fundamentally a different thing, and might have 
> some obscure potential for compatibility issues.

More information about the Es4-discuss mailing list