Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What would be the easiest way to replace chars. in a str
Message
From
08/02/2000 17:46:32
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00327059
Message ID:
00329206
Views:
29
>>PMFJI so late, but I'd handle it like this:
>>
>>for i=words(s) to 1 step -1
>> lcStr=wordnum(s, i)
>> if ctod(lcStr)#{}
>> lcNstr='{^'+lcStr+'}'
>> s=strtran(s, lcStr, lcNstr)
>> endif
>>endd
>>
>>Of course, I assumed Set Library to FoxTools :)
>
>Of course! Contrast this with using VBScript.RegExp:
>
>oRegExp = CREATEOBJ('Vbscript.RegExp')
>oRegExp.pattern = "\s(\d{4}/\d{2}/\d{2})"
>s=oRegExp.replace(s," {^$1}")
>
>This requires VBSCRIPT.DLL to be installed; this comes in with the WSH or the script component runtime; I'm not sure which.

Lucky you - not only you got this nice toy, but you also have the time to play with it. How do you do if you want to remove some characters from the found selection? Like, if you had a series of strings in a ddd-00dddd format (d for digits, 0 for zeros), and you wanted to remove the leading zeros after the dash? In VFP, I'd simply s=strtran(s, '-0', '-') as long as i can find -0 string, but I have a feeling this vbaby can do better.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform