It's difficult to know what should and shouldn't match from your limited examples, especially as I see the opposite to your claim of which matches (even after fixing your typo):
for ( 'A_TAG_HSSL_LBA_1', 'A_TAG_HSSL_LBAB_1' ) {
if( ! /A_[A_Z0-9_]+/i) {
print "$_ is not matching\n";
}
else {
print "$_ matches\n";
}
}
Produces:
A_TAG_HSSL_LBA_1 matches
A_TAG_HSSL_LBAB_1 is not matching
I think the regexp is matching somewhere other than where you think it's matching. A_TAG_HSSL_LBA_1 is matched at A_1, not at the start.
I suspect the regexp you're after is really
/^ # start of string
A_ # must start "A_"
[A-Z0-9_]+ # at least one capital, digit or underscore
$ # end of string
/ix # allow spaces and comments inside regexp
# and ignore case
Or, /^A_[A-z0-9_]+$/i in short. But, since you're ignoring case (which I just noticed), [A-Z0-9_] are just "word" characters, so your regexp reduces to: /^A_\w+$/i
Of course, this is all guesswork, so it could well be all wrong.
|