String:
"ab, ac, Convert(ab,ac), test"
I want this stringArray:
ab
ac
Convert(ab,ac)
test
,\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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.