Overview
| Artifact ID: | 2b003bcc543123aa3abd58981f9c3509388dfebe |
|---|---|
| Ticket: | 219378ffffffffffffffffffffffffffffffffff
[string range] to take index list |
| User & Date: | nobody on 2000-10-26 05:11:51 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 6023 RFE Version: 8.3.1 SubmitDate: '2000-07-19' LastModified: '2000-10-25' Severity: LOW Status: UnAssn Submitter: techsupp OS: Macintosh OSVersion: linuxppc linux-kernel 2.2.14pre9 (will be MacOS-X :-) Machine: Macintosh Blue G3 FixedDate: '2000-10-25' ClosedDate: '2000-10-25' Name: Maurice Diamantini Extensions: nothing CustomShell: nothing DesiredBehavior: "string range" should accept a list as indices arguments so the syntaxe could becomme: string range string first last instead of simply: string range string pairList ------------------------------------------------------------ Exemple: set txt "aaa123bbb679ccc" set pat {(\d+)\D*(\d+)} regexp -indices $pat $txt all var1_indexes var2_indexes # ... drop things made with indices ... # then get the chunks of txt : set var1 [string range $txt [lindex $var1_indexes 0] [lindex $var1_indexes 1]] set var2 [string range $txt [lindex $var2_indexes 0] [lindex $var2_indexes 1]] As list data type a powerfull feature of the Tcl language, I'd prefer to be able to write : set var1 [string range $txt $var1_indexes] set var2 [string range $txt $var2_indexes] Or even (if needed) set varChunk [string range $txt "$var1_indexes $var2_indexes" ] ------------------------------------------------------------ Obiously one can do a proc for it : ## String:range -- return sub-string based on pair list of indices # # Do the same as "string range" tcl command, but take a list of # two indices instead of two indices as parameters # (then extended to take an arbitrary pair list) # # example: # set txt "aaa123bbb679ccc" # set pat {(\d+)\D*(\d+)} # regexp -indices $pat $txt all var1_indexes var2_indexes # set var1 [String:range $txt $var1_indexes] # set var2 [String:range $txt $var2_indexes] # set varChunk [String:range $txt "$var1_indexes $var2_indexes" ] # proc String:range {str indices} { set res "" foreach {first last} $indices { append res [string range $str $first $last] } set res } - foundin changed to: "obsolete: 8.3.1"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "69. Other"
- title changed to: ""string range" enhancement request"
- type changed to: "RFE"