-
-
Notifications
You must be signed in to change notification settings - Fork 893
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
String.prototype.replace works incorrectly with RegExp assertion ?= #412
Comments
Can you provide specific code (like a specific regex that has a lookahead)? |
|
StringPrototype.replace polyfill |
var str = '* some list item;';
var re = /(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm;
[str.match(re), re.exec(str), str.replace(re, function () { console.log(arguments); })] in the native browser console implies there should be no match. Can you provide a specific test that passes on a compliant browser but fails on a browser where the es5-shim has polyfilled |
I mean next case: var reg = /(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm;
var str = "+ first item in list;\n\n+ second item in list;\n~0";
str.replace(reg, function () {
console.log(arguments.length);
}); For example, firefox version 24:
|
Thanks, are there specific browsers you're getting |
I am shure, firefox version 24 is one of them. |
Pass arguments to the original function
In case when we have regular expression with assertion
?=
, thewrappedReplaceValue
, which decorate the originalreplaceValue
function, can't define correct arguments, because the coincidence which was passed toreplaceValue
function don't match the RegExp pattern and the final arguments have just only two values - the offset of the matched sub-string within the whole string being examined, and the whole string being examined.There is a certain problem, when whole RegExp don't match with found coincidence, but in fact, there is a coincidence StringPrototype.replace polyfill
The text was updated successfully, but these errors were encountered: