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.