Reputation: 161
How can i split string with char that is not part of the in parenthesis string
Exemple :
"(ab);(cd)"
split with (;) ==> (ab)
and (cd)
"(ab;cd);(abcd)"
split with (;) ==> (ab;cd)
and (abcd)
I can't find the regular expression solution for this thank you for your help
Upvotes: 2
Views: 88
Reputation: 11228
@"(?<=\));(?=\()"
also works:
string str = "(ab;cd);(abcd)";
string[] arr = Regex.Split(str, @"(?<=\));(?=\()");
foreach (string str in arr)
Console.WriteLine(str);
// (ab;cd)
// (abcd)
Upvotes: 1