Regex: Named groups/backreferences

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Regex: Named groups/backreferences

liorean
Hello!

Got some questions about named groups:

"Group names must be valid lexical identifiers, and each group name
must be defined only once within a regular expression."

1. Is this meant to indicate that regex add their own lexical scopes;
partake in the lexical scope of their containing function if any; that
the identifier must be unique within the regex and that that null,
true, false, this etc. that are reserved keywords cannot be used (i.e.
the Identifier construct); or just that they need to conform to the
identifier syntax but reserved keywords are allowed (i.e. the
IdentifierName construct)?

2. Can (?P=varname) refer to a lexical variable varname from a
containing scope, or just to groups within the regex itself?

3. If it can refer to a variable in a containing scope, what
constraints are put on the variable type, what conversions are made,
etc?
--
David "liorean" Andersson
_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Regex: Named groups/backreferences

Lars T Hansen-2
On 9/13/07, liorean <[hidden email]> wrote:
> Hello!
>
> Got some questions about named groups:
>
> "Group names must be valid lexical identifiers, and each group name
> must be defined only once within a regular expression."
>
> 1. Is this meant to indicate that regex add their own lexical scopes;

No.

> partake in the lexical scope of their containing function if any;

No.

> that
> the identifier must be unique within the regex

Yes.

> and that that null,
> true, false, this etc. that are reserved keywords cannot be used (i.e.
> the Identifier construct); or just that they need to conform to the
> identifier syntax but reserved keywords are allowed (i.e. the
> IdentifierName construct)?

The latter, but thanks for asking; I should clarify that in the spec.

> 2. Can (?P=varname) refer to a lexical variable varname from a
> containing scope,

No.

> or just to groups within the regex itself?

Yes.

> 3. If it can refer to a variable in a containing scope, what
> constraints are put on the variable type, what conversions are made,
> etc?

N/A.

--lars

> --
> David "liorean" Andersson
> _______________________________________________
> Es4-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es4-discuss
>
_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Regex: Named groups/backreferences

liorean
Ah, just the answers I wanted to hear:)
--
David "liorean" Andersson
_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss