/// <summary>
/// 将传入字符串过滤掉汉字只保留IP地址
/// </summary>
/// <param name="strCharacters"></param>
/// <returns></returns>
public string FiltrateCharacters(string strCharacters)
{
string strReturnString = string.Empty;
char[] chr = strCharacters.ToCharArray();
Regex RegDecimal = new Regex("^[0-9.]+$");
for (int i = 0; i < chr.Length; i++)
{
string strSingel = chr[i].ToString();
if (RegDecimal.IsMatch(strSingel))
{
strReturnString += strSingel;
}
}
return strReturnString;
}
/// 将传入字符串过滤掉汉字只保留IP地址
/// </summary>
/// <param name="strCharacters"></param>
/// <returns></returns>
public string FiltrateCharacters(string strCharacters)
{
string strReturnString = string.Empty;
char[] chr = strCharacters.ToCharArray();
Regex RegDecimal = new Regex("^[0-9.]+$");
for (int i = 0; i < chr.Length; i++)
{
string strSingel = chr[i].ToString();
if (RegDecimal.IsMatch(strSingel))
{
strReturnString += strSingel;
}
}
return strReturnString;
}