Splitting strings from a text

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

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

thanks! but can i know what is this [^\w\s]+" ?

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

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.