About 50 results
Open links in new tab
  1. Javascript Regex: How to put a variable inside a regular expression?

    50 To build a regular expression from a variable in JavaScript, you'll need to use the RegExp constructor with a string parameter.

  2. JavaScript regular expressions and sub-matches - Stack Overflow

    Another thing to note is that RegExp.prototype.exec() and RegExp.prototype.test() execute the regular expression on the provided string and return the first result.

  3. How to extract a string using JavaScript Regex?

    String.match (regexp) is supposed to return an array with the matches. In my browser it doesn't (Safari on Mac returns only the full match, not the groups), but Regexp.exec (string) works.

  4. How do I replace all occurrences of a string? - Stack Overflow

    Basically, this question is the same as the question here: Replace " ' " with " '' " in JavaScript Regexp isn't the only way to replace multiple occurrences of a substring, far from it. Think flexible, think split!

  5. javascript - How do you use a variable in a regular expression? - Stack ...

    Jan 30, 2009 · The RegExp constructor takes 2 arguments: the expression, and flags. By using a template string in the expression, we can pass in the variable into the class, and it will transform it to …

  6. Check whether a string matches a regex in JS - Stack Overflow

    I want to use JavaScript (I can also use jQuery) to do check whether a string matches the regex ^([a-z0-9]{5,})$, and get a true or false result. match() seems to check whether part of a string matches a …

  7. How can I concatenate regex literals in JavaScript?

    Jan 26, 2017 · Is it possible to do something like this? var pattern = /some regex segment/ + /* comment here */ /another segment/; Or do I have to use new RegExp() syntax and concatenate a string? I'd …

  8. javascript - Convert string to RegExp - Stack Overflow

    Dec 14, 2015 · How can I check a JavaScript string is in a RegExp format, then convert it to RegExp? I found a way with RegExp, but the rule is too complex to make it right. function str2Regex(str){ var …

  9. Return positions of a regex match() in Javascript? - Stack Overflow

    Is there a way to retrieve the (starting) character positions inside a string of the results of a regex match() in Javascript?

  10. Case insensitive regex in JavaScript - Stack Overflow

    I want to extract a query string from my URL using JavaScript, and I want to do a case insensitive comparison for the query string name. Here is what I am doing: var results = new RegExp('[\\\\?&amp...