Str. Split andRegEx. Split. In my experience, it is a simple replacement of a single string, directly using a string. split ('single string'). Replace multiple strings with RegEx. split (string, @ "multiple strings ",Regexoptions. ignorecase). Here are two examples.
Example 1
1 String Strsample = " 11,22, 33,44, 55,66 " ;
2 String [] Sarray = Strsample. Split ( ' , ' ); // Note: here we use single quotes instead of double quotes.
3 Response. Write (sarray [ 0 ]); // Here, when the value in sarray [0] is 0, 11 is displayed. When the value is 1, 22 is displayed.
Example 2
1 Using System. Text. regularexpressions; // This reference cannot be less, because the RegEx used is in this class.
2 String Strsample = " AAA <sample> BB <sample> CC " ;
3 String [] Sarray = RegEx. Split (strsample, @" /<Sample/> " , Regexoptions. ignorecase ); // The following statement can also be used here, but it is better to use this statement from the perspective of code robustness. As for @ and/, the function is to escape,A string defined by @ is treated as a common character. escape characters are not escaped.It is worth noting that double quotation marks are used here, not single quotation marks.
4 // String [] sarray = RegEx. Split (strsample, "<sample>", regexoptions. ignorecase );
5 Response. Write (sarray [ 0 ]);