Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recursive RegEx in .NET? (?R)

Tags:

c#

.net

regex

When I use (?R) in a RegEx pattern in .NET, I get an ArgumentException:

Unrecognized grouping construct.

Does (?R) this have a different syntax in .NET?

like image 675
Rudey Avatar asked Feb 13 '23 07:02

Rudey


2 Answers

The closest thing to recursion that .NET has to offer for Regex is balancing group definition. Recursion is not directly supported in .NET.

like image 163
SynerCoder Avatar answered Feb 15 '23 10:02

SynerCoder


According to the documentation, (?R) is not a valid construct in .NET regular expressions, nor is there any mention on that page of "recursive" or "recursion" so apparently this is not supported in .NET.

like image 42
Lasse V. Karlsen Avatar answered Feb 15 '23 10:02

Lasse V. Karlsen