Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using File Search Pattern

Status
Not open for further replies.

vgwprja

Programmer
Mar 27, 2008
24
0
0
US
I am presently selecting pattern = *.txt and it works fine. I need to narrow the scope and select a pattern like this: tovecellio*.txt, it does not seem to find any files even if they are present.

Present code:

Set objRegExp = New RegExp
objRegExp.Pattern = "*.txt"
objRegExp.IgnoreCase = True

For Each objFile In fileColl
If objRegExp.Test(objFile.Name) Then........


 
Shouldn't the pattern be more like tovecellio.*\.txt

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
To add to DM4Ever's example, your selection pattern needs to be in the form of a Regular Expression which may (probably) be different that what you are used to.

You code example is using regular expressions to match patterns.

Hope this helps...

John Fuhrman
 
>I am presently selecting pattern = *.txt and it works fine.
>objRegExp.Pattern = "*.txt"
In what sense it works fine? This is blatantly non-sense. Is that your script or you're just the go-between?
 
Wow tsuji, that was a bit harsh.

Yes, it is a bit obvious the user is not aware that the code example is using regular expressions and "*.txt" would not work.

vgwprja, for that part of your code to work you will need to do some reading on how to use regular expressions for text string matching. I will warn you though, this can be daunting because of the power and flexibility of regular expressions.

Once you have done this and can post an example script of what your trying do do, we will then have a better idea of how to help you with your script.

Hope this helps you and doesn't scare you away from Tek-Tips. I have used Tek-Tips for a couple of years now and everyone (including tsuji) has been an incredible asset. dm4ever and tsuji both have a knack for seeing very creative and easily understood solutions to problems.

Thanks
John Fuhrman
 
Harsh? Absolutely and inconsiderate as well. There are other forums out there

 
If they are considerate, they won't leave thread pending after good advice is given. I am here to uphold the minimum pride of professionalism this forum and the others deserve by the efforts of their good members.
 
Leave threads pending? I'm sure that was not the intent. Sep 5 was a Friday followed by the week end (at least in the western hemisphere). Please give the orginator time to absorb and manage the thread.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top