Topic on Extension talk:Replace Text

Jonathan3 (talkcontribs)

I tried this with a regular expression replacement. It correctly showed the pages to be changed, but then just froze (I needed to hit control-C). Running runJobs.php didn't have any effect. No pages were changed.

It may have been a problem with my regex. I ended up using the web interface and just using normal text replacement. So unfortunately I can't assist much further (though happy to try things out that won't break my wiki). It may be worth looking into how replaceAll.php operates in this sort of case though. Thanks. Jonathan3 (talk) 17:24, 23 February 2020 (UTC)

Jonathan3 (talkcontribs)

Here's what I typed. Maybe the mistake will be obvious!

php replaceAll.php "{{aaa(.*)=(.*)bbb=(.*)ccc=(.*)ddd=(.*)" "{{eee$1fff=$2ggg=$3hhh=$4iii=$5" --regex --debug --summary "jjj" --user "kkk"

I also tried it without "--debug".

Ciencia Al Poder (talkcontribs)

Using regexp notation in command line parameters is tricky, because some characters like { and $ have a special meaning for the shell.

By {{ you probably want to mean template syntax. However, in regexp, the { character is used to define how many times the previous character/group/expression must be present, and you need to escape it. You probably need to replace it by \\{\\{, and the two \ are to tell the shell to interpret it as a literal \ and not a escape character for the shell itself. This should be needed only in the search string and not in the replacement string.

The $1, $2 etc in the replacement are also problematic because $ is used by the shell to indicate it's a variable name. Since it's not defined, it will replace it with blanks! You should put a single \ before all of them: \$1, \$2, etc

Jonathan3 (talkcontribs)

Thank you for the detailed response.

I hadn't escaped the { or } because the extension page states: The special characters that one can use in the search string are "( ) . * + ? [ ] |"

The other stuff is new to me - it's lucky the script made no changes were made or it would have caused me more bother!

Jonathan3 (talkcontribs)

P.S. Despite this being my fault, it would have been nice if the script had given a error message (even an unhelpful one) rather than frozen :-)

Reply to "replaceAll.php"