110,538
社区成员
发帖
与我相关
我的任务
分享
string str = "L1+L5+L12+L17 ";
MatchCollection mc = Regex.Matches(str, @"(?<=L)\d+");
foreach (Match m in mc)
{
MessageBox.Show(m.Value);
}
//如果是取數字,直接用這種方法,結果為151217
int result= int.Parse(str);
//如果分開,用這種方法,得到一個數組,數組裡的元素就是四個數字
string[] result;
result=str.Split(new char[] { 'L', '+' }, StringSplitOptions.RemoveEmptyEntries);