references/sleep-functions/matched.md

GitHub

matched

Category: Strings

Source: https://sleep.dashnine.org/manual/matched.html


Synopsis

@ matched()

returns the matches from a "string" applied to a regex 'pattern' during an ismatch/hasmatch check

Examples

Example:

if ("(654) 555-1212" ismatch '\((\d\d\d)\) (\d\d\d-\d\d\d\d)')
{
($areaCode, $phoneNumber) = matched();
println("dial 1 and $areaCode before $phoneNumber");
}

Output:

dial 1 and 654 before 555-1212

See Also

&find; hasmatch; ismatch; &join; &matches; &replace; &split