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

Specific RegExp performs differently between Dart and JavaScript #21544

Closed
DartBot opened this Issue Nov 8, 2014 · 2 comments

Comments

Projects
None yet
3 participants
@DartBot
Copy link

DartBot commented Nov 8, 2014

This issue was originally filed by ryan...@gmail.com


Consider the following:

Dart: new RegExp(r'^#{1,6}[^\n]+?$').firstMatch('#test')
JavaScript: /^#{1,6}[^\n]+?$/.exec('#test')

As these are functionally the same RegExp's, they should likely return the same result.

Dart returns null
JavaScript returns ["#test"]

In Dart, I would expect to see the equivalent of JavaScript, wrapped in a _JSRegExpMatch object, with the single group equivalent to the single string the JavaScript version returns in an array. Instead Dart returns null.

Note that if I remove the non-greedy ? after [^\n]+, it then will find a match in Dart.

I believe this is different from Issue #19193 as the above RegExp is unlikely to have catastrophic backtracking.
I'm using Dart SDK version 1.6.0_r39553 running on Mac OS X Mavericks in the Dart VM

@lrhn

This comment has been minimized.

Copy link
Member

lrhn commented Nov 10, 2014

This is a (or: yet another) bug in the VM's RegExp implementation. The VM currently uses JSCRE, which is an adaptation of PCRE to act more like ECMAScript RegExps than Perl RegExps. It falls somewhat short of that goal.

It should go away when we land the new RegExp implementation based on Irregexp, which is a RegExp engine built from scratch to match ECMAScript semantics (+ common browser extensions, but we intend to disable non-standard RegExp extensions for Dart).


Added Area-VM, Duplicate labels.
Marked as being merged into #12508.

@DartBot

This comment has been minimized.

Copy link
Author

DartBot commented Jan 29, 2015

This comment was originally written by zerny...@google.com


Fixed with the new RegExp implementation (r42312).

This issue was closed.

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