WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
23121
RegExp fails for non-greedy quatifier following negative char sets w/ single char
https://bugs.webkit.org/show_bug.cgi?id=23121
Summary
RegExp fails for non-greedy quatifier following negative char sets w/ single ...
Prestaul
Reported
2009-01-05 11:51:10 PST
RegExp fails to properly match strings when the pattern includes a non-greedy quantifier for a negative character class that only contains one character. For example: 'FAILURE'.replace(/^[^Z]*?$/g, 'SUCCESS'); // output: "FAILURE" 'FAILURE'.replace(/^[^Z]+?$/g, 'SUCCESS'); // output: "FAILURE" The greedy quantifier works: 'FAILURE'.replace(/^[^Z]*$/g, 'SUCCESS'); // output: "SUCCESS" More that one character works: 'FAILURE'.replace(/^[^ZQ]*?$/g, 'SUCCESS'); // output: "SUCCESS" Shorthand character classes work: 'FAILURE'.replace(/^[^\s]*?$/g, 'SUCCESS'); // output: "SUCCESS" 'FAILURE'.replace(/^[^\W]*?$/g, 'SUCCESS'); // output: "SUCCESS" Positive character classes work: 'FAILURE'.replace(/^[FAILURE]*?$/g, 'SUCCESS'); // output: "SUCCESS" 'FAILURE'.replace(/^[\w]*?$/g, 'SUCCESS'); // output: "SUCCESS" I've seen the bug on both Max and PC.
Attachments
Add attachment
proposed patch, testcase, etc.
Mark Rowe (bdash)
Comment 1
2009-01-05 15:48:57 PST
<
rdar://problem/6474231
>
Alexey Shvayka
Comment 2
2020-02-06 12:25:11 PST
(In reply to Prestaul from
comment #0
)
> RegExp fails to properly match strings when the pattern includes a > non-greedy quantifier for a negative character class that only contains one > character. For example: > > 'FAILURE'.replace(/^[^Z]*?$/g, 'SUCCESS'); // output: "FAILURE" > 'FAILURE'.replace(/^[^Z]+?$/g, 'SUCCESS'); // output: "FAILURE"
As of rev. 255785, both test cases output "SUCCESS". Test coverage:
https://trac.webkit.org/browser/webkit/trunk/LayoutTests/fast/regex/script-tests/pcre-test-1.js?rev=255785#L2753
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug