Page MenuHomePhabricator

Add a regex version of str_replace
Closed, ResolvedPublicFeature

Description

Feature summary
Add functionality for a regex version of str_replace. str_replace is currently available but does not support regexes.

Use case(s)

  • T27619 is stuck, but currently (on enwiki) we just add the extra variables to the filter manually, but they (or a variable containing them) needs to be copied in the filter regex for every occurrence of that letter. The expression would be more readable if we could just regex replace the added_lines.

Example

Currently:

/* Reusable letters, for when ccnorm isn't enough */
o := "ÒÔ";

exp1 := "p[" + o + "]int";

After a str_replace_regexp is available:

/* Reusable letters, for when ccnorm isn't enough */
new_added_lines := str_replace_regexp(ccnorm(added_lines), "[ÒÔ]", "o");

exp1 := "point";

Related Objects

Event Timeline

Proc updated the task description. (Show Details)
Proc updated the task description. (Show Details)
Proc renamed this task from Add gsub to Add a regex version of str_replace.Apr 17 2022, 2:43 PM
Proc claimed this task.
Proc updated the task description. (Show Details)

Change 783448 had a related patch set uploaded (by ProcrastinatingReader; author: ProcrastinatingReader):

[mediawiki/extensions/AbuseFilter@master] Add support for regex string replacements.

https://gerrit.wikimedia.org/r/783448

Daimona added a project: User-notice.
Daimona moved this task from To Triage to Announce in next Tech/News on the User-notice board.
Daimona removed a project: Patch-For-Review.

Change 783448 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Add support for regex string replacements.

https://gerrit.wikimedia.org/r/783448

Change 875277 had a related patch set uploaded (by Xxmarijnw; author: ProcrastinatingReader):

[mediawiki/extensions/AbuseFilter@REL1_35] Backport: Add support for regex string replacements.

https://gerrit.wikimedia.org/r/875277

Change 875277 abandoned by Umherirrender:

[mediawiki/extensions/AbuseFilter@REL1_35] Backport: Add support for regex string replacements.

Reason:

Release 1.35 is EOL - https://lists.wikimedia.org/hyperkitty/list/[email protected]/thread/72B3GNSDFUJEM23W54735OW34IHCZL6F/

https://gerrit.wikimedia.org/r/875277