klyn.regex.RegEx.replaceFirst
method

    public native replaceFirst(input as String, replacement as String) as String throws RegExException:

Description

Replaces the first occurrence of the pattern with a replacement string.

Parameters

Parameter | Description
--- | ---
`input` | The string where the replacement will be performed.
`replacement` | The replacement string.

Returns

The string after the replacement.

Throws

- RegExException if the regular expression cannot be evaluated.

Example

    regex = RegEx(r"\d+")
    result = regex.replaceFirst("123 abc 456", "#")  # result will be "# abc 456"