
-----------------------------------
SwAnK
Sun Feb 19, 2006 11:00 pm

Removing Commas From A String
-----------------------------------
Hey again, went through some of the turing walkthrough, and like to say it is really well done. For the string manipulation however, with "Paul Frederic Simon" how would you eliminate the spaces, yet keep the full name with the end product looking like "PaulFredericSimon"
I tried to do that below but with commas, the problem is when it finds the last comma it goes back (i-1) and leaves the rest of the sentence out. so below it would end up "Look, No" how do i get it so it outputs "Look, No, Commas!!" without any commas??? thanx again.

var sentence := "Look, No, Commas!!"

var new_name : string
var storage : string


for i : 1 .. length (sentence)

    if sentence (i) = chr (44) then
        new_name := sentence (1 .. i-1)
      
    end if
end for
put new_name

-----------------------------------
Martin
Sun Feb 19, 2006 11:36 pm


-----------------------------------
var line := "This is a line with spaces"
var newLine := ""
for i : 1 .. length(line)
    if (line(i) not= " ")
        newLine += line(i)
    end if
end for
put line

-----------------------------------
SwAnK
Mon Feb 20, 2006 8:46 pm


-----------------------------------
thanx Martin :D ,  Ive spent hours tryen to get that to work!!
