var str = "format_%A"; var format = /(?:^|\s)format_(.*?)(?:\s|$)/.exec(str); console.log(format); // ["format_%A", "%A"] console.log(format); // "format_undefined" console.log(format); // Undefined
There's nothing wrong with the regular expression. As you can see, it has matched the correct part in the first
Internet Explorer 7 and Chrome both behave as expected:
format returns "%A" (well, Internet Explorer 7 doing something right was a bit unexpected...)
Is this a bug in Firefox, or some "feature" I don't know about?