Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trimming strings
Message
From
28/02/2002 04:13:26
 
 
To
28/02/2002 03:32:46
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00626209
Message ID:
00626225
Views:
14
>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]
Previous
Reply
Map
View

Click here to load this message in the networking platform