本文共 456 字,大约阅读时间需要 1 分钟。
////// return the first match string. use regularExpression. eg. getMatchStr("abc1233dfdfa456","\d+") /// /// string /// reg string ///public string getMatchStr(string str,string regular) { MatchCollection matchCol = Regex.Matches(str, regular); if (matchCol.Count > 0) { return Convert.ToString(matchCol[0]);//这个例子是取第一个匹配的字符串 } else return ""; }
转载地址:http://pimdi.baihongyu.com/