Page MenuHomePhabricator

Search and replace not working for regexes with lookahead
Closed, ResolvedPublic


Author: riley.liam

I have recently started using the regex feature in the Edit Toolbar's Search and Replace.

I have been unable to get a regex using a lookahead to successfully replace the text. As an example, here -

Using \d (?=\w) successfully finds all the lines starting with a digit and three spaces (followed by a letter). When I click "replace all" I'm told that 123 replacements have been made, but no text is replaced. Clicking find next, then replace all tells me that 123 replacements have been made again. The replace function seems to fail when a lookaround is included in the search.

This may be just a learning issue for myself given the lack of documentation (see but what I'm doing works on which ostensibly should be doing the same thing as Wikipedia's search and replace.

Version: master
Severity: normal


Related Gerrit Patches:
mediawiki/extensions/WikiEditor : masterSearch & Replace: Use actual global replace

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:16 AM
bzimport added a project: WikiEditor.
bzimport set Reference to bz48614.
bzimport added a subscriber: Unknown Object (MLST).

What browser are you using? Not all browsers support the same features, so it could be UA-specific.

The problem seems to be with the replace, as find works.

It doesn't seem to be a problem of the browser replace, this works:
"10 W".replace(/\d+ (?=\w)/, "Foo ");

riley.liam wrote:

I'm using firefox 21 - just upgraded and the problem persists from version 20. I've downloaded the latest Google Chrome (26) and that produces the same issue.

riley.liam wrote:

Downloaded and tried on IE9 and the search and replace button in the toolbar isn't even working!

dawpa2000 wrote:

(In reply to comment #4)

Downloaded and tried on IE9 and the search and replace button in the toolbar
isn't even working!


Bug 48305 - 1.22wmf3, "Search and replace" capability not working in IE/Opera:

Bug 23992 - Search&replace disabled in IE8, Opera:

TheDJ updated the task description. (Show Details)Nov 17 2018, 9:05 PM

Change 474483 had a related patch set uploaded (by TheDJ; owner: TheDJ):
[mediawiki/extensions/WikiEditor@master] Search & Replace: Use actual global replace

Change 474483 merged by jenkins-bot:
[mediawiki/extensions/WikiEditor@master] Search & Replace: Use actual global replace

TheDJ closed this task as Resolved.Nov 19 2018, 11:52 PM
TheDJ claimed this task.
TheDJ removed a project: Patch-For-Review.
happy5214 moved this task from Backlog to Closed on the WikiEditor board.Aug 4 2019, 11:31 AM