Computer Science Canada skipping white spaces help |
Author: | Jas [ Wed May 18, 2005 9:11 pm ] | ||
Post subject: | skipping white spaces help | ||
what if an array record had a value with white spaces at the end, and u wanted to save that value, into a different variable, but without the white spaces, how would u do that. This is an example of what i mean
when i use the ", skip" i get the error "Syntax error at ',' " |
Author: | Delos [ Wed May 18, 2005 9:31 pm ] |
Post subject: | |
Well, if you can assume that the *only* white space that exists is at the end of the string, the index() the position of the first space, and extract the required string. If you have more white space, some nifty index()ing will solve things for you. If you don't know any of this, look up String Manipulation in the Tutorials. Or check out Cervantes list of Tutorials...it will help a lot! |
Author: | Jas [ Wed May 18, 2005 9:55 pm ] | ||
Post subject: | |||
acutally, the variable could have a first and last name. but the variable for sure has spaces at the end. for example:
How would you ignore the spaces in between, but "delete" the spaces at the end? |
Author: | Jas [ Thu May 19, 2005 12:28 am ] | ||
Post subject: | |||
ok took me quite a while to figure out, but i ended up with this:
|
Author: | Bacchus [ Thu May 19, 2005 6:06 am ] | ||
Post subject: | |||
couldnt you just do:
|
Author: | MysticVegeta [ Thu May 19, 2005 6:23 am ] | ||
Post subject: | |||
Yes but what if the spaces are : "Bob is bad " None of them works for that so here is my code:
|
Author: | Cervantes [ Thu May 19, 2005 7:06 am ] | ||
Post subject: | |||
I'm pretty sure he doesn't want all the spaces deleted, only the ones at the end:
The put "." is simply to show where the name string ends. |
Author: | Jas [ Thu May 19, 2005 4:18 pm ] |
Post subject: | |
wow, u really shortened it up, im impressed Cervantes!! |