match. Replacing pattern-matching substring

^string.match[pattern][search options]{replacer}
^string.match[pattern][search options][replacer]
[3.4.0]
^string.match[pattern][search options]{replacer}{returns this if the pattern wasn't be found in the string}
   [3.4.1]

The method searches the string for a match and replaces the pattern-matching substring with a substring given in curly brackets. The search mechanism is the same as in the previously given method. Automatically created matches' table
match, described in the previous method, is available within the code.

Example
$str[2002.01.01]
^str.match[(\d+)\.(\d+)\.(\d+)][g]{
Year: $match.1month: $match.2day: $match.3}

The code will output:
Year: 2002, month: 01, day: 01


Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 15.06.2012