Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d94b2416e3ac63923b4d76cd9ed60867f3fa7460
Ticket: 652953ffffffffffffffffffffffffffffffffff
regsub -code (equivalent to Perl's /e)
User & Date: nobody on 2002-12-12 21:51:56
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. 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.
    
  4. foundin changed to: "None"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "18. Commands M-Z"
  10. title changed to: "regsub -code (equivalent to Perl's /e)"
  11. type changed to: "RFE"