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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with Like or Regular Expression 1

Status
Not open for further replies.

paulbent

Programmer
Mar 4, 2002
1,071
GB
I'm processing files scanned into a drop folder. The drop filenames are in the form:

TYPE_JOBDESC_Filename.tif
TYPE_JOBDESC_Filename_Sm.jpg

Where TYPE, JOBDESC and Filename are variable length and the filename extensions are illustrative but will always be 3 chars.

I'd prefer to use the Like operator rather than distribute the vbscript dll

Before I parse the type, jobdesc and filename.ext | filename_sm.ext into database fields, I want to check the drop filename conforms to the expected pattern.

Paul Bent
Northwind IT Systems
 
You have two options. One, if you use "Option Compare Text" at the beginning of the module, the following two lines will evaluate to True:

"TYPE_JOBDESC_Filename.tif" Like "*[_]*[_]*.[A-Z0-9][A-Z0-9][A-Z0-9]"
"TYPE_JOBDESC_Filename_Sm.jpg" Like "*[_]*[_]*.[A-Z0-9][A-Z0-9][A-Z0-9]"

If you don't use that, the following is necessary:

"TYPE_JOBDESC_Filename.tif" Like "*[_]*[_]*.[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]"
"TYPE_JOBDESC_Filename_Sm.jpg" Like "*[_]*[_]*.[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]"

--With the extra "a-z" for lowercase...I know other characters are allowed in extensions, but I can't think of any graphics formats using them.

Hope this helps you out.
 
SleepDepD,

Thanks for the quick response. Sorry, forgot to say the comparison is case-insensitive. Problem is that I'm parsing on the position of the underscores and will be discarding them so

TYPE____JOBDESC_Filename.tif

with 3 addit underscores would pass the test but defeat my parsing. There should be no literal underscores within type, jobdesc or filename.ext

Paul Bent
Northwind IT Systems
 
This should work:

"TYPE_JOBDESC_Filename.tif" Like "[!_]*[!_][_][!_]*[!_][_][!_]*[!_].[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]"
"TYPE_JOBDESC_Filename_Sm.jpg" Like "[!_]*[!_][_][!_]*[!_][_][!_]*[!_][_][!_]*[!_].[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]"

Any extra underscores will return False...this is what you wanted, right? :)
 
>rather than distribute the vbscript dll

Um...vbscript.dll has actually been included in the OS since W95 OSR2, and with versions of IE since version 4. So the chances of finding it missing from a workstation is [b[very[/b] low...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top