Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Removing Commas From A String
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SwAnK




PostPosted: 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
Sponsor
sponsor
Martin




PostPosted: 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




PostPosted: Mon Feb 20, 2006 8:46 pm   Post subject: (No subject)

thanx Martin Very Happy , Ive spent hours tryen to get that to work!!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: