Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Forgive me, my regex knowledge has greatly faded over these last few years (and I didn't really know anything about them in the first place ;). What I'm trying to do is match filenames with a certain extension (say, .html for example). I also want to make sure there are no nasty character combinations (.. being the obvious one) to worry about. I have the luxury of being strict in this case. So the data I want to match will be in the format:
filename.html
Filename will contain alpha numeric (a-zA-Z0-9) characters, underscore, hyphen, and any other obviously valid filename characters. The ".html" extension in this case can be literal. So this is what I have:
/^([a-zA-Z\d_-]+)[.html]$/
Any input is greatly appreciated (:
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Simple filename regex help
by Tomte (Priest) on Jun 21, 2003 at 10:38 UTC | |
by Anonymous Monk on Jun 21, 2003 at 11:11 UTC | |
Re: Simple filename regex help
by little (Curate) on Jun 21, 2003 at 10:35 UTC | |
by Anonymous Monk on Jun 21, 2003 at 11:10 UTC | |
Re: Simple filename regex help
by vek (Prior) on Jun 21, 2003 at 15:41 UTC |