Solved

Search for a String within a String

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

Accepted Solution

by:
pcelba earned 500 total points
Comment Utility
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
Comment Utility
Thanks!
0
 

Expert Comment

by:HarrowdenIT
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now