Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Regex for matching a file name

by shenme (Priest)
on Sep 06, 2004 at 23:57 UTC ( #388886=note: print w/replies, xml ) Need Help??


in reply to Regex for matching a file name

First, you must explicitly limit what the variable name is that is being substituted, e.g.
  /${THREAD}x*.htm/
otherwise you are trying to interpolate variable "$THREADx".

Then you need to make sure the '.' is matching a period. Normally a '.' in an RE is a "match anything" character. So you would need to escape the magic meaning, e.g.
  /${THREAD}x*\.htm/

Then you want the "match anything" for "any length" where you had the asterisk, e.g.
  /${THREAD}x.*\.htm/

And... you might want to make sure you don't match "321xBOOM.htm" by saying the string '1' should come at the start of the string, e.g.
  /^${THREAD}x.*\.htm/

And you might want to wrap it up by checking that the filename _ends_ with the 'htm', e.g.
  /^${THREAD}x.*\.htm$/

Let us know if this helps!

Replies are listed 'Best First'.
Re^2: Regex for matching a file name
by Anonymous Monk on Sep 07, 2004 at 01:13 UTC
    Thanks to both you Monks, the code works perfectly!!! I certainly appreciate your fast responses.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://388886]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2019-12-11 09:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?