[ACCEPTED]-Javascript regular expression match string to start with letter or number-match
Accepted answer
Use:
^[A-Z0-9]
With a case-insensitive modifier:
if(thestring.match(/^[A-Z0-9]/i)) {}
\pL
and 2 \pN
are PCRE shortcodes and do not work in 1 Javascript.
if(/^[a-z0-9]/i.test(thestring)) {
//do something
}
.test()
is much more simple.
It returns just false
or 1 true
, while .match()
resturns null
or an array.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.