replace

From RPTools Wiki
Revision as of 13:03, 28 October 2010 by Geneocide (talk | contribs)
Jump to navigation Jump to search

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. This means if the pattern string contains any regular expression special characters they must be escaped.

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-test
This-is-a test