Last modified: 2014-04-08 08:59:34 UTC
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.
Thanks for taking the time to report this and the great analysis! Would you interested in providing a patch to fix the problem? See https://www.mediawiki.org/wiki/Developer_access and https://www.mediawiki.org/wiki/Gerrit/Tutorialfor more information.
Sorry, for personal reasons, I don't want to contribute directly to MediaWiki source code at the moment.