|
|
Grouping Parentheses in regular expressions serve two distinct functions: 1) limit the scope of subexpressions when using alternation; Limiting the scope of subexpressions using alternation is discussed elsewhere. Identifying a subexpressions allows: 1) the application of quantifiers to more than a single character in the regular expression;
Example
2) capturing text matching the subexpression(s) in addition to capturing text matching the whole regular expression. Those verbs that use the MatchInfo Table will be able use the text returned in the groupStrings cell. Captured subexpressions are returned in the order of the opening paretheses.
Example
Back referencesRegex keeps track of the matched subexpressions via an index. This allows you to refer to the matched sub-expressions within the regular expression using the back-reference metacharacter, "\digit", where digit is an integer from 1 to 9.The backslash, "\" must be escaped to enable Frontier to pass it to the regex engine. Example - finding doubled words In the case of regex.subst, backreferences can be used in the replacement text. Example - replace a doubled word with only once
|
|
||||||||||||||||||