The problem is that "?" means just that: "0 or 1 repetition of the preceding item"
Which means it's optional.
Take the "integer number" regex:
^[+-]?\d+$
What that says is "the whole string consists of at least one digit, which may be preceded by a single plus or minus"
So it matches:
0
1
123456789
-1
+0
But it won;t match
A
++0
+-999
Your regex matches "zero or one character from 'a', 'm', or 'n'" - which means that it matches anything at all!
if it was written as
^[amn]?$
Then it would match
a
n
m
But wouldn't match
b
c
9
Hello!
Get a copy of
Expresso[
^] - it's free, and it examines and generates Regular expressions.