TyraS
(Tyra)
1
Is there any code that is able to split a string based on given symbols, to determine the count of the sub strings, instead of using multiple splits?
e.g.
a [b] # c
a
b
c
This is the string [This is the bracketed string] # This is the string after hash
in the above case, splitting by # and
sub strings:
This is the string
This is the bracketed string
This is the string after hash
Yoichi
(Yoichi)
2
HI,
How about the following expression?
arrStr = System.Text.RegularExpressions.Regex.Split(yourString,"[^\w\s]+").Where(Function(s) not String.IsNullOrWhiteSpace(s)).ToArray()
Regards,
1 Like
TyraS
(Tyra)
3
thanks! but can i know what is this [^\w\s]+" ?
Yoichi
(Yoichi)
4
Hi,
In regex, [^xxxx]
means not in xxx. \w
is word character and \s
is white space character.
So, [^\w\s]
means all characters except word character and whitespace character. ≒ Special character.
Regards,
1 Like
system
(system)
Closed
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.