Topic on Extension talk:Replace Text

Regular expression and special characters

3
109.253.216.196 (talkcontribs)

In general support for using complex regular expressions seems a bit lacking. I'm trying to do a replacement for <data table="Games">[\s\S]*?<\/data> which utterly fails. But even simpler things don't work as expected. As a simple example, I tried to replace a string with special characters, namely </data> with |}}. However, no replacement I try works. If I escape the special characters, i.e. replace <\/data> with \|\}\}, I end up literally having \|\}\} in the text. If I don't escape the special characters I keep getting the awful Wikimedia\Rdbms\DBQueryError message. Any idea what's wrong?

MW 1.30.1, PHP 7.1.33, MySQL 5.7.38, ReplaceText 1.2 (REL1_30) 109.253.216.196 07:09, 25 July 2022 (UTC)

Dinoguy1000 (talkcontribs)

Have you tried escaping the < and >? I don't remember for sure if it was S:ReplaceText, but I know I've had some trouble with these characters in some flavor of regex, so that'd be the first thing I'd try.

109.253.216.196 (talkcontribs)

~~ I did. That was not the problem. I verified it by using AAA as the replacement string, which worked.

Reply to "Regular expression and special characters"