OpenEuphoria: Euphoria v4.1

# OpenEuphoria Manual

## Euphoria v4.1

routine or constant name search

| Up |  |  | TOC | Index
<< 7 Included Tools | < 8.22 Text Manipulation | Up: 8 API Reference | 8.24 Base 64 Encoding and Decoding > | 9 Release Notes >>

## 8.23 Wildcard Matching

### 8.23.1 Routines

#### 8.23.1.1 is_match

    include std/wildcard.e
    namespace wildcard
    public function is_match(sequence pattern, sequence string)

determines whether a string matches a pattern. The pattern may contain `*` and `?` wildcards.

##### Parameters:

1. `pattern` : a string, the pattern to match
2. `string` : the string to be matched against

##### Returns:

An integer, TRUE if `string` matches `pattern`, else FALSE.

##### Comments:

Character comparisons are case sensitive. If you want case insensitive comparisons, pass both `pattern` and `string` through upper, or both through lower, before calling `is_match`.

If you want to detect a pattern anywhere within a string, add `*` to each end of the pattern:

    i = is_match('*' & pattern & '*', string)

There is currently no way to treat `*` or `?` literally in a pattern.

##### Example 1:

    i = is_match("A?B*", "AQBXXYY")
    -- i is 1 (TRUE)

##### Example 2:

    i = is_match("*xyz*", "AAAbbbxyz")
    -- i is 1 (TRUE)

##### Example 3:

    i = is_match("A*B*C", "a111b222c")
    -- i is 0 (FALSE) because upper/lower case doesn't match

##### Example 4:

`.../euphoria/demo/search.ex`

##### See Also:

upper, lower, Regular Expressions

| Up |  |  | TOC | Index
<< 7 Included Tools | < 8.22 Text Manipulation | Up: 8 API Reference | 8.24 Base 64 Encoding and Decoding > | 9 Release Notes >>