Overview
| Artifact ID: | d94b2416e3ac63923b4d76cd9ed60867f3fa7460 |
|---|---|
| Ticket: | 652953ffffffffffffffffffffffffffffffffff
regsub -code (equivalent to Perl's /e) |
| User & Date: | nobody on 2002-12-12 21:51:56 |
Changes
- assignee changed to: "dkf"
- cmimetype changed to: "text/plain"
- comment changed to:
(Greg Beauchesne, [email protected]) I hope I didn't miss something, but I wanted an option in "regsub" that was equivalent to Perl's /e modifier on substitutions, and I couldn't find one. /e in Perl evaluates the subtitution string as code rather than as just a string. So, I added a -code flag to "regsub" for this purpose. For example, to decode a URL-encoded string, you can do: regsub -nocase -all -code -- {%([0-9a-f]{2})} $string {format %c 0x$1} During the substitution code, the variables $0, $1, $2, etc. are set to the match. If there were actual variables $0, $1, $2, etc. beforehand, they are restored at the end of the regsub command, but they are not accessible during the code execution. Matches which are unused are set to empty strings (to avoid errors). The replacement is done for TCL_OK and TCL_RETURN codes. TCL_BREAK will stop replacement prematurely (Not much use without -all) and TCL_ERROR or TCL_CONTINUE will cause the command to return TCL_ERROR.
- foundin changed to: "None"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "18. Commands M-Z"
- title changed to: "regsub -code (equivalent to Perl's /e)"
- type changed to: "RFE"