Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to escape regular expression's special characters using javascript?  RSS feed

 
Muneeswaran Balasubramanian
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI to all,

I am in need of escaping the regular expression special characters like '/', '.', '*', '+', '?', '|','(', ')', '[', ']', '{', '}', '\\'.

I have try with this by the following javascript but i can not achieve that.



If i go with the line which is commented,

I have the correct output.
But by with the replace method i cannot achieve that?
Please guide me to achieve that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!