klyn.regex.RegEx.replaceLast
method
public native replaceLast(input as String, replacement as String) as String throws RegExException
Description

Replaces the last occurrence of the pattern with a replacement string. Replacement capture syntax is the same as for replace.

Parameters
ParameterDescription
inputThe string where the replacement will be performed.
replacementThe replacement string.
Returns

The string after the replacement.

Throws
  • RegExException if the regular expression cannot be evaluated.
Example
regex = RegEx(r"\d+")
result = regex.replaceLast("123 abc 456", "#")  # result will be "123 abc #"