using System; using System.Text.RegularExpressions;class Test { static void Main() { string s = @" 000001: IBM 000002: 微软 "; MatchCollection ms = Regex.Matches(s, @"\d:\s*(.*?)\r\n"); foreach (Match m in ms) { string t = m.Groups[1].Value; // 这就是你要的 Console.WriteLine(t); } } }
bool GetMyString(string textBox1String,out string str1,out string str2){
string.indexof()
string.substring()
string.split()
}
........
这么多函数呢,怎么还读不出来.
string[] text = textboxtext.Split('\n');
for(int i=0;i<text.length;i++)
{
Regex.Match(textBox1.Text, @"\d+")
}
如果每段开头都是数字的话.而且段落是规则的话
using System.Text.RegularExpressions;class Test
{
static void Main()
{
string s = @"
000001: IBM
000002: 微软
";
MatchCollection ms = Regex.Matches(s, @"\d:\s*(.*?)\r\n");
foreach (Match m in ms)
{
string t = m.Groups[1].Value; // 这就是你要的
Console.WriteLine(t);
}
}
}