Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Searching for the string function
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00173714
Message ID:
00173742
Views:
28
Hi Paul,

>Is there a function that I could use that would not include records that have "WASHINGTON" in the description? In other words I only want to match whole words...

Not a single function, but you can easily simulate it with:

At( Space(1)+"WASH"+Space(1), Space(1)+Chrtran(Description,ChrTran(Upper(Description),"ABCDEFGHIJKLMNOPQRSTUVWXYZ",""),Space(255)) + Space(1) ) > 0

The inner Chrtran returns a string that contains all characters that are not the letters A-Z. This is used in the outer ChrTran to remove all thos characters from the description field and replace it with a blank. The intermediate result would for example be:

"Hello World! 123... Hi" -> " Hello World Hi "

All special characters have been replaced by blanks and a blank has been added on both sides. Now you can search for a word by adding a blank to both side of the search string. Use ATC if you need case insensitivity.

Christof
--
Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform