Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing extra spaces in MIDDLE of str.
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00535205
Message ID:
00535727
Vues:
20
>>>This will remove occurances of multiple spaces.
>>>
>>>lcStr = ALLTRIM(lcOriginalStr) && remove leading and trailing spaces
>>>DO WHILE AT(" ", lcStr) > 0 && look for double space
>>> lcStr = STRTRAN(lcStr, " ", " ", 1, 1) && convert double space to single
>>>ENDDO
>>>
>>>I do not know how to get UT to not remove spaces.
>>>
>>Use < PRE > and < /PRE > tags like this:
lcStr = ALLTRIM(lcOriginalStr)    && remove leading and trailing spaces
>>DO WHILE AT("  ", lcStr) > 0       && look for double space
>>   lcStr = STRTRAN(lcStr, "  ", " ", 1, 1)  && convert double space to single
>>ENDDO
If you hit the reply button, you'll see the actual tags.
>
>Harumph! Can't FoxTools' REDUCE function do this?? I know I can do it with VBScript.RegExp:
>
>
oReg = CREATEOBJ('VBScript.RegExp')
>oReg.Global = .T.             && FOR ALL OCCURANCES
>oReg.Pattern = '\b[\t ]+\b'   && Match any occurance of one or more spaces/tabs
>cReducedString = oReg.Replace(cUnReducedString,' ') &&Replace match with ' '
< g >Well, and unbeknownst to me, it looks like it can. I just tried:
lcstring = "John " + CHR(9) + " Smith"
? lcstring && Prints John       Smith
? Reduce(lcstring) && Prints John Smith
So apparently it can (at least in 6.0). Also placed multiple occrences of the tab and spaces between them and it still worked. **Braaaaaaaaaaaack**< sticks tongue out at Ed >:-)
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform