replace: Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) m (Macros:Functions:replace moved to replace) |
Verisimilar (talk | contribs) m (Added version.) |
||
Line 1: | Line 1: | ||
{{MacroFunction | {{MacroFunction | ||
|name=replace | |name=replace | ||
|version=1.3b48 | |||
|description= | |description= | ||
Returns the string with the occurrences of a pattern replaced by the specified value. If the number of times to perform the replacement is not specified then all occurrences of the pattern are replaced. Pattern can be a [[Macros:regular expression|regular expression]]. | Returns the string with the occurrences of a pattern replaced by the specified value. If the number of times to perform the replacement is not specified then all occurrences of the pattern are replaced. Pattern can be a [[Macros:regular expression|regular expression]]. | ||
Line 6: | Line 7: | ||
|usage= | |usage= | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
replace(str, pattern, value) | |||
</source> | |||
<source lang="mtmacro" line> | |||
replace(str, pattern, value, times) | |||
</source> | </source> | ||
Revision as of 11:28, 10 March 2009
replace() Function
• Introduced in version 1.3b48
Returns the string with the occurrences of a pattern replaced by the specified value. If the number of times to perform the replacement is not specified then all occurrences of the pattern are replaced. Pattern can be a regular expression.
Usage
replace(str, pattern, value)
replace(str, pattern, value, times)
Example
[r: replace("This is a test", " ", "-")]
[r: replace("This is a test", " ", "-", 2)]
Returns
This-is-a-testThis-is-a test