strcasematch expression function

Returns 1 if a string matches a pattern, ignoring case.

All Usage Examples

See also: strcmp, strcasecmp, strcasematch

Usage

strcasematch(pattern, s)

This function is case-insensitive. For case-sensitive matches, use strmatch.

Notes

  • Returns 1 if any patterns in the pattern string matches string s, or 0 if no patterns match.

  • In order to match, a pattern must match the s string from beginning to end. Use wildcards (*) to match substrings, e.g.

    strmatch("bar", "foobarbaz") = 0
    strmatch("*bar*", "foobarbaz") = 1
    
  • pattern is a space-separated list of one or more patterns. This can cause unintuitive behavior of this function. For example:

    strmatch("foo bar", "foo bar")
    

    will return 0, because the first argument consists of two patterns, foo and bar, and neither of those patterns match foo bar (since the pattern must match from beginning to end).

    Similarly,

    strmatch("foo bar", "foo")
    

    …will return 1, because the string matches the first of the two arguments in the pattern (foo and bar).

Examples

strmatch("FOO*", "foobar")

Returns 1.

strmatch("?baR", "fred")

Returns 0.

strmatch("FoO*,bAr*, "bar")

Returns 1.