Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trimming strings
Message
De
28/02/2002 04:13:26
 
 
À
28/02/2002 03:32:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00626209
Message ID:
00626225
Vues:
10
>I have this question if it is possible to trim a string on a specific character and replace it with blank value?
>example: I have 3 set of strings '0000001230023', '00045698000988', '002134'
>what I want is to scan on these strings and replace the zeros with '' until it reaches the nonzero value. The first string containing 6 zeros from left until it reaches the no 1 should be replace with '' the rest will remain in the string.

Hi Mike,

sure it is possible. Though I am not sure, if it could be done in VFP within one expression. Looks like you have to build a UDF with a loop, or - more elegant - use regular expressions:
loRegExp         = CREATEOBJECT('VBScript.RegExp')
loRegExp.Global  = .F.  && could improve speed, not sure though...
loRegExp.Pattern = '^0+'
? loRegExp.Replace('00045698000988','')
HTH Robert
I've acquired quite a taste for a well-made mistake... [Fiona Apple]
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform