Name

regexp

regexp [options] exp string [matchVar] [subMatchVar...]

Return 1 if regular expression exp matches string string; otherwise, return 0. If specified, matchVar will contain the portion of string that matched, whereas subMatchVar variables will contain strings matching parenthesized expressions in exp.

Options

-nocase

Ignore case in pattern matching.

-indices

Rather than storing strings in subMatchVar, store the indices of the first and last matching characters as a list.

- -

Marks the end of options.

Example

regexp {^[0-9]+$} 123
    1
    regexp {^[0-9]+$} abc
    0

Get Tcl/Tk in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.