in reply to match the name
m/AP(?:\W|$)/i;
Approximately translated: match case insensitively AP, followed by either a non-word character, or the end of the string.
This makes the assumption that AP should match unless it's immediately followed by an alpha character.
You could also just force a word boundary and have a similar outcome:
m/AP\b/i
Updated: Added a colon in the appropriate place.
Second update: It's been mentioned to me that it is possible that the OP wants a word boundary before AP. Though it wasn't explicit in his writeup, you could use either of the two RE's to make that happen:
m/\bAP(?:\W|$)/i; #or easier... m/\bAP\b/i;
Dave
|
|---|