javascript - Remove symbols by RegExp -
i need remove next symbols :
\/.?:
and tried use next regexp :
var nouse = new regexp("\/|\\|\:|\?","g"); ... var name = fullname.replace(nouse,"g"); ... but falls error :
syntaxerror: invalid regular expression: `//|\|:|?/:` nothing repeat how can change regexp?
in regexp constructor, have double escape backslashes:
new regexp("/|\\\\|:|\\?|\\.","g"); and backslash has escaped. oh , didn't have period in regex.
otherwise, can use character class:
new regexp("[/\\\\:?.]","g"); or use construct:
var nouse = /[\/\\:?.]/g;
Comments
Post a Comment