1. The longest method to intercept is as follows:
String str1 = "1, 2, 3, 4, 5, 6 ";
String [] STR = str1.split (','); // obtain an array of STR {"1", "2", "3", "4", "5 ", "6"}
Foreach (string s in Str)
{
Response. Write (S + "<br/> ");
}
// Output result:
// 1
// 2
// 3
// 4
// 5
// 6
2. Multiple characters can be captured as follows:
String str2 = "1, 2, 3, 4.5.6.7 ";
String STRM = str2.split (New char [2] {',', '.'});
Foreach (string VaR in STRM ){
Response. Write (VAR + "<br/> ");
}
// Output result:
// 1
// 2
// 3
// 4
// 5
// 6
// 7
3. You can also use system. Text. regularexpressions (the regular expression in the framework is truncated Based on the string), for example:
String str3 = "hellomrzhanghellomisslihellomrzhao ";
String [] strname = system. Text. regularexpressions. RegEx. Split (str3, "hello", system. Text. regularexpressions. regexoptions. ignorecase );
Foreach (string VaR in strname)
{
Response. Write (VAR + "<br/> ");
}
// Result
// Mrzhang
// Missli
// Mrzhao
The first parameter in RegEx. Split () can be a regular expression.