I am working on a special regex to match the javascript regex.
Now I have this regex:
/\/(.*)?\/([i|g|m]+)?/
For instance:
'/^foo/'.match(/\/(.*)?\/([i|g|m]+)?/) => ["/^foo/", "^foo", undefined] '/^foo/i'.match(/\/(.*)?\/([i|g|m]+)?/) => ["/^foo/i", "^foo", "i"]
Now I need to get this regular expression to work with:
'^foo'.match(/\/(.*)?\/([i|g|m]+)?/) => ["^foo", "^foo", undefined]
Unfortunately, my previous regex does not work for this.
Can someone help me find a regex matching this example (and others too):
'^foo'.match([a regex]) => ["^foo", "^foo", undefined]
source share