Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strip Multiple Spaces
Message
From
29/02/2000 12:45:45
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00339153
Message ID:
00339244
Views:
19
>>In another language I work with there is a function that will replace multiple spaces with a single space. Is there one for VFP?
>>
>>TIA
>
>replace fieldname with strtran(fieldname, 'xx', 'x') && use spaces instead of the x's.

Two quick items.
1. It's best to run this on TRIM(fieldname) since you could be changing trailing double spaces to trailing single spaces until the end of time.
2. The REPLACE may have to be performed several times since 4 embedded spaces will be reduced to 2 embedded spaces which needs to further be reduced to 1 embedded space. What I do is:
REPLACE STRTRAN(TRIM(fieldname),' ',' ') for ' ' $ TRIM(fieldname)
I do this successively until no replacements occur. Obviously this entire routine could be made into a function or method giving the thread originator what he is looking for.
Previous
Reply
Map
View

Click here to load this message in the networking platform