Solved

Search for a String within a String

Posted on 2014-02-03
3
379 Views
Last Modified: 2014-02-15
How can I search a string for another string?
For example I have a path = "C:\directory\test\directory\directory..."

I want to know if it is pointed to the "TEST" directory so I want to search for the word TEST that may or may not always be in the same place everytime...therefore I don't want to say look for the word test in position 3 for a length of 4 like SUBSTR...but rather look for the word TEST any where within that string and do something...

How can I look for the entire word test within another string (path)?

Thanks,
Mark
0
Comment
Question by:smithmrk
3 Comments
 
LVL 42

Accepted Solution

by:
pcelba earned 500 total points
ID: 39829974
It is easy - FoxPro offers substring test operator:

path = "C:\directory\test\directory\directory..."
IF "\test\" $ LOWER(path)
  *-- Test subfolder found
ENDIF

Other related functions are:
AT(), ATC(), OCCURS(), etc. Alternatives used for double byte characters are also available.

To replace a part of string by some other text look for:
STRTRAN(), CHRTRAN(), STREXTRACT(), STUFF(), etc.
0
 

Author Closing Comment

by:smithmrk
ID: 39830002
Thanks!
0
 

Expert Comment

by:HarrowdenIT
ID: 39861828
There's a couple of ways you can do this.

1. IF "TEST"$UPPER(lcFilePath) ....

or

2. IF AT("TEST",UPPER(lcFilePath))>0 ...

Hope this helps.

Regards
Gary
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Enabling the Skype for Business Meeting Scheduler in Hybrid OWA
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question