# waitregex

Waits a line that contains string with regular expression.

    waitregex <string1 with regular expression> [<string2 with regular expression> ...]

## Remarks

Supports Oniguruma Regular Expressions.
Pauses until the string (maximum 511 characters), which matches one or more character strings with regular expression is received from the host, or until the timeout occurs. Maximum number of the regular expression strings is 10.

If the system variable "timeout" or "mtimeout" is greater than zero, the timeout occurs when <timeout>.<mtimeout> seconds have passed. If the timeout is less than or equal to zero, the timeout never occurs.

These commands return one of the following values in the system variable "result":

Value | Meaning
--- | ---
0 | Timeout.
1 | <string1 with regular expression> has received.
2 | <string2 with regular expression> has received.
n | <stringn with regular expression> has received. n=1..10.

The received line is stored in the system variable "inputstr".
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".

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

## Example

    timeout = 30
    waitregex 'Longhorn' '.*@sai' 'Pentium\d+' 'TeraTermX{3}'
    int2str s result
    messagebox s 'result'
    messagebox inputstr 'inputstr'
    messagebox matchstr 'matchstr'

## See also

regexoption
wait
waitln