Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
trimming spaces in a string
Name: Rick Tran Date: March 12, 2002 at 14:23:17 Pacific
Comment:
Is there a command, similar to ALLTRIM, that removes the blank spaces in a string.
Name: what language?? Date: March 12, 2002 at 15:57:32 Pacific
Reply:
What are you programming in?
0
Response Number 2
Name: slash Date: March 13, 2002 at 12:30:37 Pacific
Reply:
hi , it that is java that you are progarmming in , then the commmad is .trim() , and it will trim the spaces from the end .... i dont thing that there is something like this C .
Sorry slash, thats not correct. The .trim() function will only trim the whitespaces to the right and left of the string.. not the middle. To make this really simple.. convert the string to a character array, loop through the array one space at a time and if the character isnt a white space, copy it to another character array of equal size, if it is a whitespace, increment past it... when you are done, convert the character array back into a string. There may be a function out there that will do that, but I have never used it(Assuming your using java).
0
Response Number 4
Name: Apple Date: March 13, 2002 at 14:09:39 Pacific
Reply:
ALLTRIM() only removes the spaces on the ends of a string. To remove spaces in the middle, you'll need to write your own.
This will work for the most part in java as well. I think the string implementation is slightly different, though and you can't assume that the string is terminated with a 0.
0
Response Number 5
Name: Guy Date: March 13, 2002 at 19:16:31 Pacific
Reply:
And if it is Java, then using a StringTokenizer and a StringBuffer will probably be better (faster) than .trim().
Guy
0
Response Number 6
Name: Rick Tran Date: March 14, 2002 at 07:20:50 Pacific
Reply:
Sorry for the lack of information. programming language is Visual Foxpro
0
Response Number 7
Name: Apple Date: March 14, 2002 at 12:57:02 Pacific
Reply:
Whaaa.. How scary. FoxPro string functions are best if you treat them a little like C strings. Using silly commands like MEMOLINE or whatever will actually slow you down.
LOCAL i * tcString = some string FOR i = LEN( tcString ) TO 1 STEP -1 ch = SUBSTR( tcString, i,1 ) IF( ch == ' ' ) THEN tcString = SUBSTR( tcString, 1,i-1 ) + ; SUBSTR( tcString,i+1 ) ENDIF NEXT
Summary: update---- i was able to make a function to remove the vowels in a string.. however, the way i have the function set up it puts a space where a vowel was. is there a way to delet the spaces in the st...
Summary: Hi I need to find out how to query the last character in a string: Im querying if there is characters A or B or C as last char within string. scenario Test marks for various subjects. FrenchA FrenchB ...
Summary: I have a string whic is made up of multiple words seperated by commas and has space in the trailling end also . I need to remove the spaces in the trailing end alone. example string is given below exa...