I have following string:
string text = "Find string inside brackets [C#.net [C# Only] [PHP and SQl [MySQL] ] ] and [Vb.net] examples.";
and I want to output is like this:
1 - [C#.net [C# Only] [PHP and SQl [MySQL] ] ]
2 - [C# Only]
3 - [PHP and SQl [MySQL] ]
4 - [MySQL]
5 - [Vb.net]
My Code is
string regularExpressionPattern = @"\[([^]]*)\]";
string text = "Find string inside brackets [C#.net [C# Only] [PHP and SQl [MySQL] ] ] and [Vb.net] examples.";
Regex re = new Regex(regularExpressionPattern);
int i = 0 ;
foreach (Match m in re.Matches(text))
{
i++;
Console.WriteLine(i + " - " + m.Value);
}
and output(wrong):
1 - [C#.net [C# Only]
2 - [PHP and SQl [MySQL]
3 - [Vb.net]
Aucun commentaire:
Enregistrer un commentaire