Re: Stripping characters from a string
- From: Glenn Jackman <glennj@xxxxxx>
- Date: 26 Jun 2007 23:33:31 GMT
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
.
- Follow-Ups:
- Re: Stripping characters from a string
- From: Ralf Fassel
- Re: Stripping characters from a string
- From: tcltkdev
- Re: Stripping characters from a string
- References:
- Stripping characters from a string
- From: tcltkdev
- Re: Stripping characters from a string
- From: Jeff Godfrey
- Re: Stripping characters from a string
- From: Alexandre Ferrieux
- Re: Stripping characters from a string
- From: Donal K. Fellows
- Re: Stripping characters from a string
- From: Alexandre Ferrieux
- Re: Stripping characters from a string
- From: tcltkdev
- Stripping characters from a string
- Prev by Date: Re: Create Files/ Upload Files
- Next by Date: Re: Iconized application takes looooong to wake up
- Previous by thread: Re: Stripping characters from a string
- Next by thread: Re: Stripping characters from a string
- Index(es):