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 -

javascript - How to process users in one specific order using map o each function? -

javascript - Linking from page A to a specific iframe on page B -