Removing Commas From A String
Author |
Message |
SwAnK
|
Posted: Sun Feb 19, 2006 11:00 pm Post subject: 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.
code: | 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 |
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Martin

|
Posted: Sun Feb 19, 2006 11:36 pm Post subject: (No subject) |
|
|
code: | 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
|
Posted: Mon Feb 20, 2006 8:46 pm Post subject: (No subject) |
|
|
thanx Martin , Ive spent hours tryen to get that to work!! |
|
|
|
|
 |
|
|