Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a STRTRAN function which is not case sensitive
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00650635
Message ID:
00650675
Views:
21
>is there a Strtran function (or similar) which will replace text but in a case insensitive manner, e,g,
>
>Abc=Strtran(MyFruit,'Apples','Coca Cola')
>Abc=Strtran(MyFruit,'apples','Coca Cola')......
>
>otherwise I will need to put every possible combination of 'Apples' in using Upper and lower case
>
>I am using Strtran on a memo field, so it is not possible just to upper it first

The following not fully tested code will do it.
lcMemo = mymemo
lcSearchExpr = "Apple"
lcReplaceExpr = "Coca Cola"
lnPos = Atc(lcSearchExpr, lcMemo)
DO WHILE lnPos > 0
  lcMemo = STUFF( lcMemo, lnPos, Len(lcSearchExpr), lcReplaceExpr )
  lnPos = Atc(lcSearchExpr, lcMemo)
ENDDO
Make sure that lcReplaceExpr doesn't include lcSearchExpr otherwise it'll create endless loop.
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform