Otto currently uses the builtin regexp package for regular expressions, which lacks support for backreferences. The reasoning behind this is rather well explained (the godoc page for the regexp module links to this elaborate blog post) - in short, implementing lookbacks is impossible while still guaranteeing O(n) execution time.
Unfortunately, as long as Otto uses it, it cannot conform to the ECMA 5 specification, and a large amount of existing JS code out there will simply fail to compile on Otto - notably, both BabelJS and Traceur, the two major ways available to provide ES6 features to ES5-compatible environments, are currently incompatible with Otto.
I propose the move to a different regular expression library - this one, for example, looks rather promising, and doesn't add a cgo dependency.
Otto currently uses the builtin
regexppackage for regular expressions, which lacks support for backreferences. The reasoning behind this is rather well explained (the godoc page for theregexpmodule links to this elaborate blog post) - in short, implementing lookbacks is impossible while still guaranteeingO(n)execution time.Unfortunately, as long as Otto uses it, it cannot conform to the ECMA 5 specification, and a large amount of existing JS code out there will simply fail to compile on Otto - notably, both BabelJS and Traceur, the two major ways available to provide ES6 features to ES5-compatible environments, are currently incompatible with Otto.
I propose the move to a different regular expression library - this one, for example, looks rather promising, and doesn't add a cgo dependency.