KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to build a javascript regex based on user input: function FindString(input) { var reg = new RegExp('' + input + ''); // [snip] perform search } But the regex will not work correctly when the user input contains a ? or * because they are interpreted as regex specials. In fact, if the user puts an unbalanced ( or [ in their string, the regex isn't even valid. What is the javascript function to correctly escape all special characters for use in regex?
Tags (comma-separated)
Save Edits
Cancel