in reply to Re^2: Hlelp regarding regex
in thread Hlelp regarding regex

Ideally, you'd provide a list of more than 2 strings, but your description helps. The following will probably suit your needs:
my @list = ( # Good "\\\\files\\builds\\data\\M9998SBQCACSYD30401S", # Bad "\\\\files\\builds\\data\\M9998SBQCACSAD30401S", ); for my $x (@list) { if ($x =~ /Y[A-Z]\d[^\\]*$/){ print "$x - matches\n"; } else { print "$x - doesn't match\n"; } }
Given that these are file paths, I personally would rely on File::Basename or File::Spec to separate the filenames from the directories before doing the tests. That way the code would still work on other platforms.