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
Post a Comment