-
c#正则表达式排除不要的
如下举例筛选str字符串中非十六进制字符,得到新的目标字符串strRet;
string str = "abcdsefghias12321312";//需要筛选的目标字符串
string pattern = "[A-Fa-f0-9]";//表示十六进制字符
string strRet = "";
MatchCollection results = Regex.Matches(str, pattern);
foreach (var v in results)
{
strRet += v.ToString();
}
string str = "abcdsefghias12321312";//需要筛选的目标字符串
string pattern = "[A-Fa-f0-9]";//表示十六进制字符
string strRet = "";
MatchCollection results = Regex.Matches(str, pattern);
foreach (var v in results)
{
strRet += v.ToString();
}