This is not necessarily the current version of this TIP.
| TIP: | 75 |
| Title: | Refer to Sub-RegExps Inside 'switch -regexp' Bodies |
| Version: | $Revision: 1.13 $ |
| Authors: |
Donal K. Fellows <donal dot k dot fellows at man dot ac dot uk> János Holányi <csani at lme dot linux dot hu> Salvatore Sanfilippo <antirez at invece dot org> |
| State: | Accepted |
| Type: | Project |
| Tcl-Version: | 8.5 |
| Vote: | Done |
| Created: | Wednesday, 28 November 2001 |
| Discussions To: | http://purl.org/mini/cgi-bin/chat.cgi |
| Keywords: | switch, regexp, parentheses |
Currently, it is necessary to match a regular expression against a string twice in order to get the sub-expressions out of the matched string. This TIP alters that so that those sub-exps can be substituted directly into the body of the script to be executed.
Similarly to the
regexp -- <RE> $string matchvar submatchvar ...
of Tcl and the
interact -re <RE> {
set matches "$interact_out(0,string) $interact_out(1,string) ..."
}
of Tcl/Expect, it would be very helpful and would also make Tcl more consistent if the [switch] command of Tcl would support references to parenthesized REs inside the switch patterns from the bodies associated to each of the patterns. As it is, it is currently necessary to match the regular expression against the string twice to obtain this information.
The easiest way to get the information