Q:

regex checking inside of quotation marks

I am working on a regex that can apply arguments like this 
!($1~/^[A-Z0-9]{1,25}$/)

but only apply this argument to objects that are surrounded by quotation marks. In other words, the code inside the variable that is checked may look both like AAA0123 and "AAA0123". I need it to only check the AAA0123 part validity.
A full snippet of code 
!($1~/^[A-Z0-9]{1,25}$/) {print "1st field invalid";}

A:

You may use a grouping construct ((...)) with an alternation operator | to introduce an alternative for your alphanumeric pattern, just the same pattern but inside double quotation marks:
/^([A-Z0-9]{1,25}|"[A-Z0-9]{1,25}")$/
  ^              ^^              ^^

If you do not use a group, like ^[A-Z0-9]{1,25}|"[A-Z0-9]{1,25}"$, the ^ and $ anchors will get applied to the alternatives separately allowing partial string matches.

