Solved

Search for a String within a String

Posted on 2014-02-03
3
368 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Fox Pro commands 15 50
Creating an empty sheet in an existing PDF and adding a watermark 9 746
Data Import from a CSV file 8 497
SQLite with C# using SQLiteWrapper 3 715
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…
Is your phone running out of space to hold pictures?  This article will show you quick tips on how to solve this problem.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

840 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