需求描述:
a. 将before and before and before变成after and after and after (替换所有的before为after)
b. 将before and before and before变成after and after and before (替换前两个before为after)
操作方法:
1. Python
a.
b.
2. Tcl
a.
b.
set subject "before and before and before"
regsub "before" $subject "after" result
for {set i 0} {$i < [expr 2 - 1]} {incr i} {
regsub "before" $result "after" result
}
puts "$result"