我正在制作一个接受带有任何小数(0-9),+,*或#的输入的正则表达式,但不应接受任何字母(az).
所以数字就像
#192#
*31#+ 32475728966
0479266315
32495959511
应该被接受.
当字符串中有任何字母时,正则表达式无效.
#192#abbef
a0479266315
这是我到目前为止的正则表达式:
private const string PhoneNumberRegex = "((\\d)|(\\*)|(\\#)|(\\+))?"; private bool IsValid(inputString) { // Accept * # + and number Match match = Regex.Match(inputString, PhoneNumberRegex, RegexOptions.IgnoreCase); return match.Success; }
但是这个正则表达式在#192#abbef上也会返回true
我怎样才能解决这个问题?