public static string getRegexString(string LengthString,string strRegex, string param)
...{
string s = "";
Regex reg = new Regex(strRegex);
Match match = reg.Match(LengthString);
if (match.Success)
...{
if (param == "")
...{
s = match.ToString();
}
else
...{
s = match.Groups[param].Value.ToString().Trim();
}
}
return s;
}
本文介绍了一个使用C#实现的正则表达式匹配函数示例。该函数接受目标字符串、正则表达式及一个参数,返回匹配到的内容。通过实例展示了如何使用正则表达式来提取字符串中的特定信息。
1568

被折叠的 条评论
为什么被折叠?



