Take a look at PHP.JS’s implementation of PHP’s preg_quote
function, that should do what you need:
The special regular expression characters are: . \ + * ? [ ^ ] $ ( ) { } = ! < > | : -
More Related Contents:
- Escape string for use in Javascript regex [duplicate]
- Regex to match all instances not inside quotes
- JavaScript Regex, where to use escape characters?
- How to properly escape characters in regexp
- How to properly escape characters in regexp
- What’s the best way to validate an email address in JavaScript?
- Why this javascript regex doesn’t work?
- Converting user input string to regular expression
- Regular Expression for password validation
- Recursive matching with regular expressions in Javascript
- How to find indices of all occurrences of one string in another in JavaScript?
- Converting any string into camel case
- Return positions of a regex match() in Javascript?
- How to split a long regular expression into multiple lines in JavaScript?
- Works in Chrome, but breaks in Safari: Invalid regular expression: invalid group specifier name /(?
- Javascript – return string between square brackets
- How to prevent Javascript injection attacks within user-generated HTML
- regex street address match
- How to remove backslash escaping from a javascript var?
- regex javascript to match both RGB and RGBA
- jQuery Youtube URL Validation with regex
- Replace function not replacing [duplicate]
- Include Arabic characters in JavaScript regular expression?
- Optimize long lists of fixed string alternatives in regex
- Replace certain arabic words in text string using Javascript
- What does the “Nothing to repeat” error mean when using a regex in javascript?
- Regular expression for number with length of 4, 5 or 6
- Use RegExp to match a parenthetical number then increment it
- Regex – Repeating Capturing Group
- How do you split a javascript string by spaces and punctuation?