The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

core.regexp

Regular expression matching and substitution functions.

match

Description

Returns a list of matches from the given text for the supplied pattern. PCRE modifiers ``/ig`` are implied.

Usage

<pattern> <text>

Examples

    :emphasize-lines: 2

    (match "\d+" "The year 2014 saw precisely 10 things happen.")
    ("2014" "10")

replace

Description

Replaces any matches of pattern in the given text with the given string. PCRE modifiers ``/ig`` are implied.

Usage

<pattern> <replacement> <text>

Examples

    :emphasize-lines: 2

    (replace "hundred" "billion" "You have won a hundred dollars!")
    "You have won a billion dollars!"