You need to pass the second parameter:
var r = new RegExp(keyword, "i");
You will also need to escape any special characters in the string to prevent regex injection attacks.
More Related Contents:
- Regular expression to get a string between two strings in Javascript
- How to count string occurrence in string?
- Replace multiple strings with multiple other strings
- How can I extract a number from a string in JavaScript?
- How to remove all line breaks from a string
- Regular Expression to get a string between parentheses in Javascript
- Fastest method to escape HTML tags as HTML entities?
- Split large string in n-size chunks in JavaScript
- Check for special characters in string
- How to find indices of all occurrences of one string in another in JavaScript?
- Use dynamic (variable) string as regex pattern in JavaScript
- Regular expression which matches a pattern, or is an empty string
- Javascript – return string between square brackets
- Remove whitespace and line breaks between HTML elements using jQuery
- Convert camelCaseText to Title Case Text
- javascript regular expression to check for IP addresses
- How to extract base URL from a string in JavaScript?
- Wrap tags around http text
- How to extract a string using JavaScript Regex?
- match() returns array with two matches when I expect one match
- Split string on the first white space occurrence
- Javascript unicode string, chinese character but no punctuation
- Split a string based on multiple delimiters
- How do I split a string by whitespace and ignoring leading and trailing whitespace into an array of words using a regular expression?
- Replacing accented characters with plain ascii ones [duplicate]
- Best way to parse HTML in Javascript
- Use RegExp to match a parenthetical number then increment it
- Get filename from string path in javascript?
- Removing backslashes from strings in javascript
- Find and replace nth occurrence of [bracketed] expression in string