Re: Stripping characters from a string



At 2007-06-26 06:51PM, "tcltkdev@xxxxxxx" wrote:
To recap my post, I need to strip a string of certain chars. So which
of the code posted best suit my need?

% set oldstring "the quick *brown fox (+jumps) over the 2 lazy dogs!"

% set newstring [strip oldstring "()+1234567890"]

% puts $newstring

% "the quick brown fox jumps over the lazy dog"

<nitpick>
Where'd the "*" go? It wasn't in your chars to omit.
Why are there quotes around $newstring?
</nitpick>

Anyway, here's one answer:
proc strip {string chars} {
return [join [split $string $chars] ""]
}


--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
.