Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random text in memo field
Message
From
23/03/2023 16:54:25
 
 
To
22/03/2023 15:14:40
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01686399
Message ID:
01686405
Views:
59
Thank you John.

>Hi Denis
>
>>>Product A 10$
>>>Product B 20$
>>>Product C
>>>Product D
>
>It should be possible to use Regex transformations to remove words containing $, e.g. using Craig Boyd's excellent Regex fll.
>
>But for a pure VFP solution: If you can be sure there's no spaces inside the price and no other content mixed into it, then something like this should get rid of it:
>
>
>lcstring="Product A $20 More content"
>
>local liAt,lcLeft
>lcString=chrtran(m.lcString,chr(9)," ")  &&in case free text tab
>liAt=at("$",m.lcString)
>do while m.liat>0
>   lcLeft=left(m.lcString,m.liat)
>   lcLeft=left(m.lcLeft,rat(" ",m.lcleft))
>   lcString=substr(m.lcString,m.liAt)
>   lcString=substr(m.lcString,at(" ",m.lcString)) 
>   lcString=alltrim(m.lcLeft)+" "+alltrim(m.lcString)
>   liAt=at("$",m.lcString)
>ENDDO
>? lcstring
>
>This code handles multiple prices, $20 as well as 20$ and will preserve any content after the price, which does no harm if the price is always last but in any case is easily prevented by not bothering with the rest of the lcString once you grab the lcLeft.
*******************************************************
Save a tree, eat a beaver.
Denis Chassé
Previous
Reply
Map
View

Click here to load this message in the networking platform