Reputation: 31
String:
"ab, ac, Convert(ab,ac), test"
I want this stringArray:
ab
ac
Convert(ab,ac)
test
Upvotes: 1
Views: 68
Reputation: 174696
Just split your input acccording to ,\s+
or , +
regexes. \s+
matches one or more space characters.
string value = "ab, ac, Convert(ab,ac), test";
string[] lines = Regex.Split(value, @", +");
foreach (string line in lines) {
Console.WriteLine(line);
}
Output:
ab
ac
Convert(ab,ac)
test
Upvotes: 0
Reputation: 67968
,\s*(?![^(]*\))
Try this.Replace by \n
.See demo.
https://regex101.com/r/nL5yL3/28
This will work on inputs like ab, ac, Convert(ab,ac),test,bc,mc,
too
Upvotes: 1