The regexp Command
The regexp command provides direct access to the regular expression matcher. Not only does it tell you whether a string matches a pattern, it can also extract one or more matching substrings. The return value is 1 if some part of the string matches the pattern; it is 0 otherwise. Its syntax is:
regexp ?flags? pattern string ?match sub1 sub2...?
The flags are described in Table 11-6:
-nocase | Lowercase characters in pattern can match either lowercase or uppercase letters in string. |
-indices | The match variables each contain a pair of numbers that are in indices delimiting the match within string. Otherwise, the matching string itself is copied into the match variables. |
-expanded | The pattern ... |
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.