Your specification is extremely unclear. Could you possibly explain what exactly you're wanting to verify about the Y character in the string?
If you have trouble explaining what you want, you should at least give a list of examples of strings that you do want to match, and a counter list of failed matches.
The below regex matches your string, but given your unclear spec, it probably isn't useful.
my $x = "\\\\files\\builds\\data\\M9998SBQCACSYD30401S";
if ($x =~ /Y\D\d+\D*$/){
print "This matches something, don't know if it's really what you
+want";
}