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
  • 13,144
  • 12
  • 92
  • 130

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
  • 39,270
  • 4
  • 65
  • 132
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
  • 328,213
  • 58
  • 503
  • 561