regexp

regexp ?-option ...? exp string ?matchVar? ?subMatchVar ...?

Finds the regular expression exp in string. It gives 1 for a match and 0 for no match, and sets matchVar to the match and each subMatchVar to a group. Put exp in braces, so that Tcl does not change its backslashes.

Options

Option What it does
-nocase Matches letters with no case.
-all Finds each match. It gives the count of matches.
-inline Gives the match and its groups as a list, and sets no variable. With -all, each match and its groups.
-indices Gives the start and end index of each match in place of the text.
-start INDEX Starts the search at INDEX.
-line ^ and $ match at each line, and . does not match a newline.
-expanded White space and # comments in exp are ignored.
-about Gives the count of groups and the flags of exp.

Examples

A click on an example runs it in the shell of the page.

Errors

Facts