Abdi
Abdi

Reputation: 19

tcl search and replace multiple occurances

I have multiple lines in html file containing:

xxxxxx"./FSsacdss12s.tcl.html#::FSxxxxt_15" target="main">::FSxxxxxt</a></dt>
xxxxxx"./FSsacdss12s.tcl.html#::FSxxxxt_15" target="main">::FSxxxxxt</a></dt>
xxxxxx"./FSsacdss12s.tcl.html#::FSxxxxt_15" target="main">::FSxxxxxt</a></dt>

I would like to search and remove all occurrences of FS from each line, resulting in:

xxxxxx"./sacdss12s.tcl.html#::xxxxt_15" target="main">::xxxxxt</a></dt>

I have tried:

set ToLft_ "^|\./|\[^a-zA-Z]|\::"
set ToRght_ "\[^a-zA-Z]|$" 
regsub -all ($ToLft_)FS($ToRght_) $line "" line 

Without any success.. Any suggestions is very much appreciated!

Regards,

Upvotes: 1

Views: 1564

Answers (2)

regsub -all "FS" $line "" line

Upvotes: 2

glenn jackman
glenn jackman

Reputation: 246817

The simplest way is to use string map to replace all occurrences of "FS" with an empty string:

set line [string map {FS ""} $line]

Upvotes: 6

Related Questions