Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replace character expression
Message
De
08/07/2010 13:28:13
 
 
À
08/07/2010 11:45:37
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01471799
Message ID:
01471905
Vues:
38
>>>abcdefg [01] = is what i need
>>>as opposed to submitted data which reads # abcdefg [1]
>>
>>Well, in that case you could just brute-force it in 10 lines of code, no RegEx needed, maintainable in pure VFP:
>>
>>cFile = strtran(cFile,"[0]","[00]") && if you need to handle [0]
>>cFile = strtran(cFile,"[1]","[01]")
>>cFile = strtran(cFile,"[2]","[02]")
>>cFile = strtran(cFile,"[3]","[03]")
>>cFile = strtran(cFile,"[4]","[04]")
>>cFile = strtran(cFile,"[5]","[05]")
>>cFile = strtran(cFile,"[6]","[06]")
>>cFile = strtran(cFile,"[7]","[07]")
>>cFile = strtran(cFile,"[8]","[08]")
>>cFile = strtran(cFile,"[9]","[09]")
>>
>>* or, if you wanted to do it in "one line of code", you could nest the above calls < eg >
>>
>>Some people might pooh-pooh brute-force solutions, but they have their place.
>
>You didn't write a loop? Tsk, tsk...

Nah, I just did what any half-decent optimizing compiler would do, which would be to unroll the loop.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform