in reply to Simple filename regex help

/^([a-zA-Z\d_-]+)[.html]$/

[.html] is a character class, so it won't match the whole fileextension, but only the first character of it, and because of the $ no name with any extension will match.

/^([a-z0-9_-]+)\.html$/i

should do the trick, notice the i (ignore case), to make the regexp more readable IMVHO.

Edit:added \ to the regexp.

regards,
tomte


Hlade's Law:

If you have a difficult task, give it to a lazy person --
they will find an easier way to do it.

Replies are listed 'Best First'.
Re: Re: Simple filename regex help
by Anonymous Monk on Jun 21, 2003 at 11:11 UTC

    Thanks for the explanation :)