https://bugzilla.wikimedia.org/show_bug.cgi?id=56228
Web browser: ---
Bug ID: 56228
Summary: "replace all" does not work with a regular expression
that contains a caret or a dollar
Product: MediaWiki extensions
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: Unprioritized
Component: WikiEditor
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Mobile Platform: ---
Hello,
The algorithm for "replace all" in WikiEditor, as described in a comment in
modules/jquery.wikiEditor.dialogs.config.js, is the following: "Instead of
using repetitive .match() calls, we use one .match() call with /g and indexOf()
followed by substr() to find the offsets."
In general, this does not work when regular expression mode is turned on and
the regular expression contains "^" or "$", because calling indexOf on the
matched text ignores the constraint that this text must be at the beginning/end
of a line.
Example:
* Open a page in edit mode and set the text of the edit box to "aa"
* Open the search and replace dialog of WikiEditor.
* Set "search for" to "a$"
* Set "replace with" to "b"
* Enable "Treat search string as a regular expression"
* Click "Replace all"
Expected result: "ab"
Real result: "ba"
What happens: the content of the only match is "a", and the first occurrence of
"a" in "aa" is at position 0.
--
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l