Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Strtran preserving case
Message
 
 
À
20/08/2009 10:11:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01419229
Message ID:
01419240
Vues:
51
Check code by Steven Black

message #650683 and other messages in that thread.

>>>I need to make a mass replace of one word to another word but I want to preserve the case.
>>>
>>>Example I want to change TheOldWord to TheNewWord. But if the theoldword is this way then it needs to be thenewword or if is TheOLDWord it needs to be TheNEWWord or THEOLDWORD to THENEWWORD. I don't know all the cases that it might be in.
>>>
>>>I was hoping to not have to use ATC to find the word then loop checking the case with isupper and islower functions.
>>
>>
>>Check the last parameter of the STRTRAN function:
>>
>>? STRTRAN("My THEOLDWORD is all upper", "TheOldWord", "TheNewWord",1,-1,1+2)
>>? STRTRAN("My theoldword is all lower", "TheOldWord", "TheNewWord",1,-1,1+2)
>>? STRTRAN("My TheOldWord is cammel case", "TheOldWord", "TheNewWord",1,-1,1+2)
>>
>
>That doesn't work. STRTRAN("My TheOldWord is cammel case","theoldword","thenewword, 1, -1, 3) Doesn't preserve the case. The note in the help file states "The case of cReplacement changes only if the string found is all uppercase, lowercase, or proper case."
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform