Reputation: 4921
i am using following regex expression to replace
query=query.replace(/[^a-zA-Z 0-9*?:.+-^""_]+/g,'')
But when my query is diam!@#%d
i get diam@d
after execution of this.
it means it is not replacing @
. Why is so ??
Upvotes: 1
Views: 248
Reputation: 56162
You need to escape -
sign in your regex (-
=> \-
), i.e.: [^a-zA-Z 0-9*?:.+\-^""_]+
, therefore it will match: !@#%
.
Upvotes: 3