From: Arnold Snarb on 28 Apr 2010 18:50 Binome asked: > > I'd like to delete spaces from a string. No, you don't. > I have 2 strings "111" and "111", I use concat to get "111 111" > and now I want to get "111111". In that case, you shouldn't have used [concat] in the first place. > Does someone know what instruction I need? Not really, but I have a few guesses: * If you have "111" and "111" and want "111111", ==> then just say "111111" in the first place! * If you have two arbitrary strings $a and $b (which might be, but are not necessarily, "111" and "111") and want to jam them together without any spaces in between, ==> then say [set c "$a$b"]. $c will have the answer. * If you have an arbitrary number of strings and you want to jam them together without any spaces in between ==> then say [join $listOfStrings ""] * If you have something other than the above, and you want something other than the above, ==> then think about your problem some more and ask again. --Arnold
From: Prof Craver on 29 Apr 2010 00:15 On Apr 28, 11:39 am, Jeff Godfrey <jeff_godf...(a)pobox.com> wrote: > string map {" " ""} "this is my string" > returns --> thisismystring One can also use {join "this is my string" ""}, exploiting the fact that Tcl's list implementation tidies up many whitespace issues automatically. And to think, half the online stores in the world still can't handle spaces in a credit card number.
From: Donal K. Fellows on 29 Apr 2010 04:16 On 29 Apr, 05:15, Prof Craver <xcottcra...(a)gmail.com> wrote: > On Apr 28, 11:39 am, Jeff Godfrey <jeff_godf...(a)pobox.com> wrote: > > string map {" " ""} "this is my string" > > returns --> thisismystring > > One can also use {join "this is my string" ""}, > exploiting the fact that Tcl's list implementation tidies up > many whitespace issues automatically. That will only work on values that are well-formed lists. The version with [string map] handles any string. Donal.
First
|
Prev
|
Pages: 1 2 Prev: How to "make install" while not a root? Next: How to capture text in tk widget |