I have three string called This_is string1
and This is string2
There_is string3
How to split these 3 strings after \"This_\", \"T
The answer is simple, you can use the String.Split method, specifying the multiple delimiters (in your case the underscore and whitespace):
str.Split(new char[]{'_',' '})
LinQPad result:
If you want to split only the first part, you can use the 2nd overload of String.Split:
str.Split(new char[]{'_',' '}, 2);
and this is the result in LinQPad:
So you want to split only the first part? You can use the overload of String.Split that allows to specify the count and multiple delimiters:
str.Split(new[]{' ', '_'}, 2);
So on the first string you get: "This"
+ "is string1"
, similar on the others.