in reply to Validate windows filenames.

Two things. Character classes, [], makes alternatives read easier, and always, always, always specify what you ALLOW.

sub sanitize_it { $_[0] =~ s/[^\w.,\-={}()\[\]!@#\$%^&'`~]/$_[1]/g; return $_[0]; }

Good Day,
    Dean

Replies are listed 'Best First'.
Re^2: Validate windows filenames.
by zzspectrez (Hermit) on Aug 04, 2005 at 04:26 UTC

    +++
    Im still learning to use regexes and havent used character classes. Good example.

    Thanks..

    zzSPECTREz