Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a STRTRAN function which is not case sensitive
Message
From
30/04/2002 10:55:20
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00650635
Message ID:
00650869
Views:
22
>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
>
>Regards,
>
>Gerard

Yet another strtranc :)
FUNCTION strtranc
LPARAMETERS tcString, tcSearch, tcReplace
tcSearch = upper(tcSearch)
LOCAL lnOccurences,lnLen,ix
lnOccurences = OCCURS(tcSearch, UPPER(tcString))
IF lnOccurences=0
	RETURN tcString
ENDIF
lnLen = LEN(tcSearch)
FOR ix=1 TO lnOccurences
	tcString = STUFF(m.tcString,ATC(m.tcSearch,m.tcString,m.ix),;
		m.lnLen,m.tcSearch)
ENDFOR
RETURN STRTRAN(tcString, tcSearch, tcReplace)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform