references/sleep-functions/ismatch.md

GitHub

ismatch

Category: Strings

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


Synopsis

"string" ismatch 'pattern'

Determine if the string matches the specified pattern.

Parameters

"string" - the string to check

'pattern' - a regular expression pattern that defines a substring to match for

    1. Regular Epxressions - tutorial on regular expression language

Side Effects / Notes

  • Text captured from the pattern is stored and made available via the &matched function.

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; &join; &matched; &matches; &replace; &split