Other Commands That Use Regular Expressions

Several Tcl commands use regular expressions.

  • lsearch takes a -regexp flag so that you can search for list items that match a regular expression. The lsearch command is described on page 64.

  • switch takes a -regexp flag, so you can branch based on a regular expression match instead of an exact match or a string match style match. The switch command is described on page 71.

  • The Tk text widget can search its contents based on a regular expression match. Searching in the text widget is described on page 463.

  • The Expect Tcl extension can match the output of a program with regular expressions. Expect is the subject of its own book, Exploring Expect (O'Reilly, 1995) by Don Libes.

Get Practical Programming in Tcl & Tk, Third Edition 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.