in reply to Re: Regular Expression Help
in thread Regular Expression Help

One of my problems is not to allow file names without extentions and with no less than 3 characters.

Replies are listed 'Best First'.
Re^3: Regular Expression Help
by ikegami (Patriarch) on Jan 06, 2006 at 16:46 UTC
    No problem. Just use the second snippet instead of the third one.
Re^3: Regular Expression Help
by Anonymous Monk on Jan 06, 2006 at 16:48 UTC
    How do I say match anything but not allow spaces between words? Like:
    if($filename=~/.*!\s[.](?!bat$|exe$).*$/gi){...
    This is not working if I use .*!\s

      ikegami's second regular expression will still do what you want.

      This only allows the characters a-z (upper and lower case) for the file name and an extension of 3 of the same characters. No spaces allowed, no weird characters.
      My recommendation is to use this one.

      Also, for general questions on regex, take a look at perlre. This will answer many of your questions and broaden your overall understanding of regular expressions.