General information
Category:
Coding, syntax & commands
>>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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only