Solved

Search for a String within a String

Posted on 2014-02-03
3
387 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

732 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