Regex bug
Bug Description
Hermes version: 0.12.0 OS version (if any): ubuntu 20.04 Hi. The code below does not have the same behavior as other engines (e.g., V8 in Google Chrome,SpiderMonkey in Firefox,chakra in Edge,quickjs,jerryscript). This test case works correctly in other js engines with returning a matched result, but in hermes return null.
Steps To Reproduce
1.var regex=/((?:(?:|[A-Z])((?:n*.)){1}))+(?:\2\2*)/; 2.regex.exec("NnnX")

The Expected Behavior
[ "Nnn", "n", "n" ]

Hi,
Thank you for your feedback. We are taking a look at the issue.
John Paul
Hi, is this confirmed to be a bug?
Yes, I have confirmed that Hermes is not outputting the same as other engines. I have also reduced the repro to the following:
var p = typeof(globalThis.print) === "undefined" ? globalThis.console.log : globalThis.print;
var regex=/^((n*.){1})+\1/;
p(regex.exec("nn"));
Running this in Hermes prints null, but outputs a match in V8.
Thanks a lot! I tried this repro and it did print null. However I want to confirm whether https://github.com/facebook/hermes/issues/950 really a duplicate of this, because though the regex of them are the same, the behaviors are not. This matches nothing and prints null but https://github.com/facebook/hermes/issues/950 returns a wrong matched result.
Yes they are coming from the same bug. This regex is different so it's expected that the end result would be different. The trigger of the bug seems to be {1} quantifier. In both issues you opened, and in the repro I provided, removing the {1} in the regex makes Hermes output the correct match.
Yes they are coming from the same bug. This regex is different so it's expected that the end result would be different. The trigger of the bug seems to be
{1}quantifier. In both issues you opened, and in the repro I provided, removing the{1}in the regex makes Hermes output the correct match.
Fine, thanks.
Confirmed, the bug still exists.