How to check digits present in javascript string or not

I need regexone that checks that the string contains only A-Z, A-Zand special characters, but not digitsie ( 0-9). Any help is appreciated.

+3
source share
4 answers

You can try with this regex:

^[^\d]*$

And an example:

var str = 'test123';
if ( str.match(/^[^\d]*$/) ) {
  alert('matches');
}
+6
source

Plain:

/^\D*$/

This means any number of characters other than numbers. Look in action ...

An alternative is to cancel the test. Just check if a digit is present using the trivial:

/\d/

... and if that matches, your line will fail.

+3
source

: ^[A-Za-z.,!@#$%^&*()=+_-]+$.

^ $ , .

0

:

var re = /^[a-zA-Z!#$%]+$/;

-

0

All Articles