The asterisk (*) special character is used in JavaScript regular expressions to match zero or more occurrences of the previous item.
var StringToTest = 'abc1';
var IsFound = /^\w{3}\d*$/.test(StringToTest);
alert(IsFound);
The preceding code will return true for any three-character string, followed by zero or more digits.
Related articles:
JavaScript Regular Expressions
JavaScript Regular Expression Special Characters: $ ^
Filed under: JavaScript, Programming, Software, Web | Leave a Comment »