Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## proc sstring {src arg rpc}
- 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
- set len [string length $src]
- set len [incr len -1]
- # set idx -1
- while {$idx != -1} {
- set idx [string first $src $arg]
- if {$idx != -1} {
- # puts $idx
- set arg [string replace $arg $idx [expr $idx+$len] $rpc]
- # puts "$arg $idx $src"
- if {$all != 1} {set idx -1}
- }}
- return $arg
- }
- example:
- set input "\[{(niet doe maar niet toch niet"
- set repl "welletjes"
- set srch "niet"
- #puts $input
- puts [sstring $srch $input $repl]
Add Comment
Please, Sign In to add comment