Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing extra spaces in MIDDLE of str.
Message
De
25/07/2001 14:04:13
 
 
À
25/07/2001 13:47:59
Peter Brama
West Pointe Enterprises
Detroit, Michigan, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00535205
Message ID:
00535222
Vues:
18
>Whoops - UT removed my spaces... there are 10-20 spaces between the FirstName and the LastName, all in one string.
>
>>Is there any VFP routines that can remove (or replace) multiple space occurances in the middle of a string?
>>
>>I am processing data from another source. The NAME comes across as:
>>
>>FirstNameLastName
>>
>>I'd like to strip out the multiple spaces and leave it with just one space.

Peter --

Try this. I've coded it in several statements for clarity, but these could be combined in one line if needed for performance.
c = "Joanna                Smith"
c = ALLTRIM (c)         && Leading spaces need to be removed for this to work.
n = ATC (" ", c)        && Find the first space in the middle of the phrase
cNew = LEFT (c, n) + ALLTRIM (SUBSTR (c, n + 1))   &&  Use that location to reconstruct the string.
Enjoy!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform