Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random text in memo field
Message
From
22/03/2023 15:14:40
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
 
 
To
22/03/2023 09:52:39
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01686399
Message ID:
01686402
Views:
57
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.
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform