in reply to matching file names using regex

How about haveing 2 checks?

if (/^test\d+.*/ && !/~$/)

___________
Eric Hodges

Replies are listed 'Best First'.
Re: Re: matching file names using regex
by halley (Prior) on Apr 29, 2004 at 18:43 UTC
    The benefit for two checks is that each rule can be tuned separately. You might realize there are a number of weird endings that you don't like, such as m{ [#@$.~] $ }x.

    The negative aspect of using two regex to check legality is that it's a bit harder to supply a rule in a configuration file, such as those used by spam filters, etc. If your code can't handle two supplied regex, then you'll have to figure out one.

    A negative look-behind is useful.

    print if m{ ^ # begins with test # 'test' \d+ # a number .*? # nothing or anything else (?<! ~ ) # but no '~' at the tail $ # to the end }ix;

    --
    [ e d @ h a l l e y . c c ]