I'm working on a special regex to match a javascript regex.
For now I have this regex working:
/\/(.*)?\/([i|g|m]+)?/
For example:
'/^foo/'.match(/\/(.*)?\/([i|g|m]+)?/) => ["/^foo/", "^foo", undefined]
'/^foo/i'.match(/\/(.*)?\/([i|g|m]+)?/) => ["/^foo/i", "^foo", "i"]
Now I need to get this regex working with:
'^foo'.match(/\/(.*)?\/([i|g|m]+)?/) => ["^foo", "^foo", undefined]
Unfortunately my previous regex doesn't work for that one.
Can someone help me to find a regex matching this example (and others too):
'^foo'.match([a regex]) => ["^foo", "^foo", undefined]