4

I really like perl's Regexp::Grammars module. Is there anything like this for .NET?

I'd really like to use a recursive descent parser in a regex style way (eg searching for a matching pattern through a large document) in C#, and be able to express that pattern recursively.

Update After reading this little gem from brian d foy, I discovered that perl 5.10 supports labeled subpatterns using (?&NAME). PCRE now has a Nuget package, and PCRE supports named/labeled subpatterns.

Matthew Lock
  • 12,582
  • 11
  • 88
  • 124

2 Answers2

5

Perl5 Regexp::Grammars is modeled after Perl6 grammars.

Niecza is a Perl6 implementation that implements grammars and targets the CLI, which .NET also does.

daxim
  • 38,703
  • 4
  • 63
  • 128
2

I don't think that there is a comparable module, but you can create recursive regexes in .NET. See here for an example.

Community
  • 1
  • 1
Tim Pietzcker
  • 313,408
  • 56
  • 485
  • 544