Regex doesn't work as expected in javascript
I created a regex to test the name where only "_", "-", ",". "Are allowed.
Here's a regular expression:
^[a-zA-Z][a-zA-Z0-9\.\-_']{1,24}$
The problem is that this resolving name has @
, Check Demo screenshot :
var str = "deepak@";
var str2 = "@@";
alert(str.match("^[a-zA-Z][a-zA-Z0-9\.\-_]{1,24}$"));//allowing why?
alert(str2.match("^[a-zA-Z][a-zA-Z0-9\.\-_]{1,24}$"));//not allowing
Expected: The name having @
should not admit.
Note. When I checked this regex at https://regex101.com/#javascript it works well
+3
source to share