Use the RegExp object constructor to create a regular expression from a string:
var re = new RegExp("a|b", "i");
// same as
var re = /a|b/i;
More Related Contents:
- Fastest method to escape HTML tags as HTML entities?
- Removing all script tags from html with JS Regular Expression
- What is the best way to parse html in google apps script
- How to prevent Javascript injection attacks within user-generated HTML
- Javascript regular expression to validate URL
- Javascript regex returning true.. then false.. then true.. etc [duplicate]
- How to wrap part of a text in a node with JavaScript
- Increment a number in a string in with regex
- Remove specific HTML tag with its content from javascript string
- What is the best way to parse html in google apps script
- Removing backslashes from strings in javascript
- Remove everything within script and style tags
- Find and replace nth occurrence of [bracketed] expression in string
- Date Format UTC in javascript [duplicate]
- Is it possible to append to innerHTML without destroying descendants’ event listeners?
- What is the max size of localStorage values?
- How to get the body’s content of an iframe in Javascript?
- Named capturing groups in JavaScript regex?
- Trigger Change event when the Input value changed programmatically?
- Show hide divs on click in HTML and CSS without jQuery
- ReferenceError: $ is not defined
- Performance differences between visibility:hidden and display:none
- Save and render a webpage with PhantomJS and node.js
- How to create new instance of an extended class of custom elements
- How can I get an element’s ID value with JavaScript?
- Regular expression for number with length of 4, 5 or 6
- How to pass data from one page to another page html
- How can I get the progress of a downloading ?
- Jquery change text between two elements
- Getting a sticky header to “push up”, like in Instagram’s iPhone app using CSS and jQuery