The (^1|2)
matches 1
at the start of the string and 2
anywhere in a string. Similarly, (10|12|14|16$)
matches 10
, 12
and 14
anywhere inside a string and 16
at the end of the string.
You need to rearrange the anchors:
/^[12](?:[RLXYB]|EURO)(?:10|12|14|16)$/
See the regex graph:

Details
^
- start of string
[12]
- 1
or 2
(?:[RLXYB]|EURO)
- R
, L
, X
, Y
, B
or EURO
(?:10|12|14|16)
- 10
, 12
, 14
or 16
$
- end of string
NOTE: If you use ==~
operator in Groovy, you do not need anchors at all because ==~
requires a full string match:
println("1EURO16" ==~ /[12](?:[RLXYB]|EURO)(?:10|12|14|16)/) // => true
println("1EURO19" ==~ /[12](?:[RLXYB]|EURO)(?:10|12|14|16)/) // => false
See the Groovy demo.