|
DEELX Extended Syntax: Recursive Expression
Return: Content | Prev: Conditional expression | Next: Match Mode
Recursive Expression (?R)
"Recursive expression" is to refer to another part of expression itself, not to refer to what is captured. If the part which is referred, contains the "recursive expression", this makes a recursion.
Remarks
"Recursive expression" is to refer to another part of expression itself, not to refer to what is captured. For example:
Expression |
Equivalent1 |
Equivalent2 |
Matches |
(\w)(?1) |
(\w)(\w) |
|
ab |
(?1)(\w(?2))(\d) |
(?1)(\w(\d))(\d) |
(\w(\d))(\w(\d))(\d) |
a1b23 |
If the part which is referred, contains the "recursive expression", this makes a recursion. For example:
Expression |
Equivalent1 |
Equivalent1 |
Matches |
(\w(?1)?)
|
(\w(\w(?1)?)?) |
(\w+) |
ghjk5...... |
\(([^()]|(?R))*\) |
\(([^()]|\(([^()]|(?R))*\))*\) |
|
(a * (c + 2)) |
Formats of recursive expression:
Format |
Description |
(?R) |
Recursively refer to the whole expression. |
(?R1), (?R2) |
Recursively refer to certain group. |
(?1), (?2) |
(?R<named>) |
Recursively refer to named group. |
(?R'named') |
|
|
|