Is there a version of JavaScript’s String.indexOf() that allows for regular expressions?

Instances of the String constructor have a .search() method which accepts a RegExp and returns the index of the first match. To start the search from a particular position (faking the second parameter of .indexOf()) you can slice off the first i characters: str.slice(i).search(/re/) But this will get the index in the shorter string (after … Read more