SHARE
TWEET

Untitled

a guest Dec 16th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## proc sstring {src arg rpc}
  2. proc sstring {args} { set all 0;set idx 0; if {[lindex $args 0] eq "-all"} { set args [lrange $args 1 end]; set all 1 }; lassign $args src arg rpc; # go on as usual with your 3 arguments
  3. set len [string length $src]
  4. set len [incr len -1]
  5. # set idx -1
  6. while {$idx != -1} {
  7. set idx [string first $src $arg]
  8. if {$idx != -1} {
  9. # puts $idx
  10. set arg [string replace $arg $idx [expr $idx+$len] $rpc]
  11. # puts "$arg $idx $src"
  12. if {$all != 1} {set idx -1}
  13. }}
  14. return $arg
  15. }
  16.  
  17. example:
  18.  
  19.  
  20. set input "\[{(niet doe maar niet toch niet"
  21. set repl "welletjes"
  22. set srch "niet"
  23. #puts $input
  24. puts [sstring $srch $input $repl]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top