Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching to another Regex library #215

Open
liclac opened this issue Sep 14, 2016 · 5 comments
Open

Switching to another Regex library #215

liclac opened this issue Sep 14, 2016 · 5 comments
Assignees

Comments

@liclac
Copy link
Contributor

liclac commented Sep 14, 2016

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.

@paulocoutinhox
Copy link

+1

@deoxxa
Copy link
Collaborator

deoxxa commented Sep 15, 2016

This sounds good, but we'd need to make sure there were no performance regressions. Basically the same problem as #205 right now. I'd happily merge a patch if it made otto better support JS's RegExp object without serious performance degradation.

@dszczyt
Copy link

dszczyt commented Mar 22, 2018

what about a build tag to allow to choose regexp compatibility over performance ?

@stevenh
Copy link
Collaborator

stevenh commented Nov 28, 2022

Would consider that, if someone wants to put in a PR 👍

@stevenh
Copy link
Collaborator

stevenh commented Dec 6, 2022

Would love some feedback on this PR which implements pluggable RegExp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants