0

Looking for a regEx expression that will return the method name then the strings inside the method body, for each method. method name will always be between void and (

void MyMethodName(....)
{

   code

   code

   code "string 1"

   code "string 2"

}
Flatlineato
  • 1,066
  • 15
  • 32
Eric Blair
  • 117
  • 2
  • 12

1 Answers1

1

For getting the method name use this expression:

void (\w+)\(

The name will then be in the first group of the match.

But parsing a real programming language with regular expressions will not work (consider code fragments in string literals for example). I suggest that you look into parser generators:

What is a good C# compiler-compiler/parser generator?

Community
  • 1
  • 1
Markus Palme
  • 659
  • 4
  • 15