c# - Split string separated by multiple spaces, ignoring single spaces -
i need split string separated multiple spaces. example:
"aaaa aaa bbbb bbb bbb cccccccc" i want split these:
"aaaa aaa" "bbbb bbb bbb" "cccccccc" i tried code:
value2 = system.text.regularexpressions.regex.split(stringvalue, @"\s+"); but not success, want split string multiple spaces, not single space.
+ means "one or more", single space qualify separator. if want require more once, use {m,n}:
value2 = system.text.regularexpressions.regex.split( stringvalue, @"\s{2,}"); the {m,n} expression requires expression prior match m n times, inclusive. 1 limit required. if upper limit missing, means "m or more repetitions".
Comments
Post a Comment