Regex.IsMatch(str, '^[0-9]*[1-9][0-9]*$')
场景:Regex.IsMatch(str,"[0-9]*[1-9][0-9]*$")是什么意思?该怎么解决
Regex.IsMatch(str,"^[0-9]*[1-9][0-9]*$")是什么意思?
如下面的是判断为整数 :
#region 判断是否为正整数
public static bool IsValidNumber(string str)
{
return Regex.IsMatch(str, "^[0-9]*[1-9][0-9]*$ ");
}
#endregion
请问:
1:^[0-9]*[1-9][0-9]*$ 是什么意思?
2:再帮我写一个判断是float的函数
------解决方案--------------------
楼主没学过正则?
------解决方案--------------------
up
------解决方案--------------------
try
public static bool IsValidNumber(string str)
{
return Regex.IsMatch(str,@ "^([1-9][0-9]*\.[0-9]*|0\.(?!0+$)[0-9]*)$ ");
}
------解决方案--------------------
mark
Regex.IsMatch(str,"^[0-9]*[1-9][0-9]*$")是什么意思?
如下面的是判断为整数 :
#region 判断是否为正整数
public static bool IsValidNumber(string str)
{
return Regex.IsMatch(str, "^[0-9]*[1-9][0-9]*$ ");
}
#endregion
请问:
1:^[0-9]*[1-9][0-9]*$ 是什么意思?
2:再帮我写一个判断是float的函数
------解决方案--------------------
楼主没学过正则?
------解决方案--------------------
up
------解决方案--------------------
try
public static bool IsValidNumber(string str)
{
return Regex.IsMatch(str,@ "^([1-9][0-9]*\.[0-9]*|0\.(?!0+$)[0-9]*)$ ");
}
------解决方案--------------------
mark