Search code examples
regexmediawikiexpr

Calculating with AutoWikiBrowser


I'm using regular expression in AutoWikiBrowser to replace the input of several values with just one value, such as this:

|value1=4
|value2=5
|value3=6

To this:

|value={{#expr:4+5+6}}

While the correct result does show on the page, it does not look good in the code itself, so I'm trying to find a way to make it the result only (in this case value=15) but so far no luck. Can someone help me with out showing how to make this possible?

P.S. I tried the search function but didn't find a similar question.


Solution

  • MediaWiki parser allows the templates can be subst'ed, ie replaced by their rendering. That's also true for parser functions call.

    You can subst a template prefixing the template call by subst:.

    |value={{subst:#expr:4+5+6}}

    Reference: Substitution on MediaWiki manual

    Example: diff (the expression used is in the edit summary, the result in the diff)