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:
00650910
Views:
37
> 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')......

I have a function I use that parses through occurrances in a string using OCCURS() and AT() and then uses STUFF() to insert the replacement string into the primary string at the appropriate location. If you look for the target string in the string searched while both are converted to uppercase, you will get case-independant results. After all, AT() returns the location in the string and a location is a number and a number is independant of case!

Here's my code:
* change something in the clipboard text (could just as well be a variable)
DO WHILE OCCURS("strtran(", LOWER(_CLIPTEXT))>0
   _CLIPTEXT=STUFF( _CLIPTEXT, AT("strtran(", LOWER(_CLIPTEXT) ), ;
      LEN( "strtran(" ), "STRT(" )
ENDDO
...Art
http://members.aol.com/ARTGR/
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform