RegExp help
I have a regular expression that compares a string. It is as follows:
var string = new RegExp( ' [ ' + leters + ' ][ ' + letters + ' 0-9]+ ' ); This is used to check if a string starts with a letter and then letters or numbers. how do I modify this so it can start with letters OR numbers, instead of just letters? Thanks |
First, I suppose it is Javascript language.
Next, I find very strange the way you write this regex, and with way too many spaces; programming leaves little room for approximation… Your example would have been simpler as “new Regex('[A-Z][A-Z0-9]+','i')” and then it would still have been false, missing the extra “^” at the start of the regex to match only at the start of the string. As for the answer, something like this should do: “new Regex('^[A-Z0-9]{2,}','i')”. Yves. |
All times are GMT -5. The time now is 11:01 PM. |