Could any one suggest code to remove mentioned special characters: []{}<>
Code inside the JavaScript tags:
var name="formattting[]{}<>";
rename = name.replace(/[<{>}([)]/g,"");
Output:
formattting]
Here out of six special symbols, five symbols are removed and now my concern is to remove the special character ]
.
答案 0 :(得分:2)
Try this:
rename = name.replace(/[[\]{}<>]/g, "");
答案 1 :(得分:1)
You need to escape special characters in regex:
var name="formattting[]{}<>";
rename = name.replace(/[\$<{>}9\(\[\)\]]/g,"");
alert(rename)
答案 2 :(得分:0)
简单地逃避\]
var name="formattting[]{}<>";
var rename = name.replace(/[<{>}([)\]]/g,"");
alert(rename);