# strmatch

Matches the target string with the regular expression. (version 4.59 or later)

## Format

    strmatch <target string> <string with regular expression>

## Remarks

Supports Oniguruma Regular Expressions.
This command searches the <target string> with the <string with regular expression>.
The "strmatch" command returns one of the following values in the system variable "result":

Value | Meaning
--- | ---
0 | Not matched.
1 | Matched offset(1origin).

The first matched pattern is stored in the system variable "matchstr".
Group matched patterns of regular expressions are stored in 9 system variables from "groupmatchstr1" to "groupmatchstr9".
Also, these system variables will not be changed when the pattern does not match.

When a user searches the multi-byte string like as Japanese, the user must configure the regular encoding by using the regexoption previously.

## Example

    strmatch 'Microsoft Windows XP [Version 5.1.2600]' '\[(Version (\d+).(\d+).(\d+))\]'

    int2str s result
    messagebox s 'result'                        ; 22
    messagebox matchstr 'matchstr'               ; [Version 5.1.2600]
    messagebox groupmatchstr1 'groupmatchstr1'   ; Version 5.1.2600
    messagebox groupmatchstr2 'groupmatchstr2'   ; 5
    messagebox groupmatchstr3 'groupmatchstr3'   ; 1
    messagebox groupmatchstr4 'groupmatchstr4'   ; 2600

## See also

- regexoption
- strreplace
- strinsert
- strremove