Notepad on-line
string number = "9813f";string regexPattern = @"^\d{5}$";if (!Regex.IsMatch(number, regexPattern)){ errorMessage = "The number is invalid (not a 5-digit number)."; return false;}
In javascript:if(number.match(/^\d+$/)) return true;Another example:return email.match(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
Post a Comment
1 comment:
In javascript:
if(number.match(/^\d+$/))
return true;
Another example:
return email.match(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
Post a Comment