Archive for April 16, 2007

JavaScript Regular Expression Plus Sign +

Posted in JavaScript, Software, Web, programming on April 16, 2007 by Joey

The Plus Sign (+) special character is used in JavaScript regular expressions to match one or more occurrences of the previous item.

var NumberToTest = '1234';
var IsFound = /^\d+$/.test(NumberToTest);
alert(IsFound);

The preceding code will return true for any length of digits that begin and end with a digit.

Related articles:
JavaScript Regular Expressions
JavaScript Regular Expression Special Characters: $ ^