Regular Expressions

Several Tcl commands, including regexp, support the use of regular expressions:

regex | regex

Match either expression.

regex *

Match zero or more of regex.

regex +

Match one or more of regex.

regex ?

Match zero or one of regex.

.

Any single character except newline.

^

Match beginning of string.

$

Match end of string.

\c

Match character c.

c

Match character c.

[abc]

Match any character in set abc.

[^abc]

Match characters not in set abc.

[a-z]

Match range of characters a through z.

[^a-z]

Match characters not in range a through z.

(regex)

Group expressions.

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.