Extension talk:ReplaceSet

From MediaWiki.org
Jump to navigation Jump to search

ReplaceSet and Defaultsort[edit]

At first, this extension seemed to me an ideal solution for automating "defaultsorting", correcting or adapting the default key by which MW sorts pages in categories. So I added the following syntax to a template:


In other words, if the value for the magic word "Defaultsort" isn't manually defined, then the default sortkey is determined using ReplaceSet to substitute characters with diacritics for characters without diacritics.

However, this is not what happened. All pages are instead sorted under the symbol "<", which obviously, isn't very helpful. Is this due to a bug, a syntax error or something else entirely? Cavila MW 1.17, MySQL 5.5.16, Php 5.3.8 10:53, 21 May 2012 (UTC)

Aha! I did a few tweaks and found out that leaving a bit of space between some of the squirly bracket solved it - an undifferentiated sequence of them is not understood, apparently. Maybe it's a bug or a limitation to using parser functions, but nothing specifically to do with ReplaceSet, I suppose. Cavila MW 1.17, MySQL 5.5.16, Php 5.3.8 11:36, 21 May 2012 (UTC)

Upper limit of number of arguments?[edit]

I get an error saying something like ”the limit in number of calls to the function ReplaceSet is reached”. Would be nice if the limits where documented here! rotsee (talk) 13:02, 3 November 2012 (UTC)

  • I use #replaceset only once on page and two replace, but get error ”the limit in number of calls to the function ReplaceSet is reached” Antohabio (talk) 16:02, 18 May 2017 (UTC)

Replacing Equals Sign[edit]

In the documentation, it says I should be able to replace an equals sign using the following code. However, when I tried it, the string is unchanged. Other substitutions are working as they should. Am I missing something obvious? (MW 1.19.2, PHP 5.3.16, MySQL 5.5.21) -- Mw.clearish (talk) 09:41, 10 January 2013 (UTC)

You update to the latest version? = support is part of the most recent version. Daniel Friesen (Dantman) (talk) 09:57, 10 January 2013 (UTC)
Thanks, that was the problem! I'd originally followed the link to Special:ExtensionDistributor/ReplaceSet and selected 1.19.x. Now I've got the Git master instead. -- Mw.clearish (talk) 10:55, 10 January 2013 (UTC)

Replacing round bracket[edit]

There is any way to use round bracket '(' as replacing text? If I try to do that, following error is output: The regex pattern "(" is missing the ending delimiter ')'. --Arex rus (talk) 04:49, 18 May 2013 (UTC)

I devised. I used a regex pattern. For example:
{{#replaceset:Any ( text|/\(/i=-}}
would produce Any - text. --Arex rus (talk) 05:21, 18 May 2013 (UTC)

how do i[edit]

I have the following field in a template where users usually paste e-mails:

! Problem Details
|  [[Problem Details::{{{Problem Details|}}}]]

the problem is, when e-mails contain characters [, ] and | the form goes crazy. I tried using Replaceset to change these characters into something else (doesn't really matter, can be changed to "-" for example but it did not work.

Any ideas how to do this? 12:59, 22 April 2014 (UTC)

This doesn't really look like a ReplaceSet issue. For starters try using the #set function instead. Daniel Friesen (Dantman) (talk) 19:32, 22 April 2014 (UTC)
Hello, it actually is and I managed to replace everything but pipe characters:

I now have this and it replaces ] and [ with - but this does not work with |. How can I escape that?

 |  [[Problem Details::{{#replaceset:{{{Problem Details|}}}|/\[/i=-|/\]/i=-}}]] 07:03, 23 April 2014 (UTC)

The traditional trick is to create a Template:! with just the contents | and then use {{!}} where you need a |. Daniel Friesen (Dantman) (talk) 07:16, 23 April 2014 (UTC)
The problem is, the data is entered into a form by users and they would have to replace every pipe with the template caller. I know that and I am looking for a way that does this automatically. 08:35, 23 April 2014 (UTC)
If there are pipes in the template invocation then anything after them won't even exist as part of the Problem Details variable. There's simply no way around that.
Also I seriously recommend you switch to using #set instead of SMW's link style location. That notation is not intended for use in templates and the escaping you're doing would become pointless since as a parser function #set doesn't suffer any of the deficiencies that the link syntax has. Daniel Friesen (Dantman) (talk) 09:07, 23 April 2014 (UTC)
Thank you. How can I use #set in a form? Normally I would have this syntax with #replaceset: | [[Problem Details::{{#replaceset:{{{Problem Details|}}}|text to replace=text after replace}}]]
I know with set I cannot use this sytax and I also have to use #show to display the data. So I came up with this:

| {{#set:Problem Details}}{{#show:{{PAGENAME}}|?Problem Details}} but it does not work. How do I pass the text from the input form into the #set function? 10:41, 23 April 2014 (UTC)

| {{#set:Problem Details={{{Problem Details|}}}}}{{{Problem Details|}}} Daniel Friesen (Dantman) (talk) 10:53, 23 April 2014 (UTC)
Thank you very much but it seems to do the very same thing as [[Problem Details::{{{Problem Details|}}}]] :( 12:14, 23 April 2014 (UTC)