jeudi 30 juillet 2015

Regex and matching in perl

I have an array with CA, C, CB, CZ. I want an if statement to match only C, CB, CZ.

@array = ("CA", "C", "CB", "CZ");

foreach (@array) {
if ($_ =~ m/^C|^C.&[^CA])
print "true \n";
}

This doesn't work, but I think it might be close. What perl regex expressions can I use to achieve my goal?

Aucun commentaire:

Enregistrer un commentaire