var patt = /^(?=.*[a-zA-Z0-9.!@#&*\-\u0080-\u052F])[a-zA-Z0-9\s.!@#&*',\-\u0080-\u052F]*$/;
console.log(patt.test("\u002f"));
I know that u002f is a forward slash in Unicode. I've tried adding that to the pattern as well as "/" and haven't been able to get it to log true yet.
You can escape a /
character, by using \/
.
Using unicode will actually result in the absolute same result, as using the character itself - and therefore will not solve your problem.
It is easy to add a forward slash, just escape it. No need using any character references or entities.
var patt = /^(?=.*[a-zA-Z0-9.!@#&*\-\u0080-\u052F])[\/a-zA-Z0-9\s.!@#&*',\-\u0080-\u052F]*$/;
^
var patt = /^(?=.*[a-zA-Z0-9.!@#&*\-\u0080-\u052F])[\/a-zA-Z0-9\s.!@#&*',\-\u0080-\u052F]*$/;
alert(patt.test("/test"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With