Regex to capture text block

2

I need to extract blocks of text that are inside #regions:

#region VARIAVEIS GLOBAIS
string aux1 = "teste";
string aux2 = "teste2";
...
#endregion

The return would be:

string aux1 = "teste";
string aux2 = "teste2";
...

How do I do this with RegEx?

Remembering that each region has a different name.

    
asked by anonymous 02.08.2015 / 19:28

1 answer

1

I'm not a C # developer but this regular expression solves this problem, you need to see what it looks like in your code:

(?<=#region VARIAVEIS GLOBAIS).*?(?=#endregion)

Example: link

    
02.08.2015 / 21:09