javascript - Allow "/" forward slash in regular expression -


var patt = /^(?=.*[a-za-z0-9.!@#&*\-\u0080-\u052f])[a-za-z0-9\s.!@#&*',\-\u0080-\u052f]*$/; console.log(patt.test("\u002f")); 

i know u002f forward slash in unicode. i've tried adding pattern "/" , haven't been able log true yet.

it easy add forward slash, escape it. no need using 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"));


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -