I am doing a parser for nand2tetris project. I want to check if the destination field is either M|D|MD|A|AM|AD|AMD
and their different ways of combinations like MA
not only AM
.
^(M|D|MD|A|AM|AD|AMD)\s*=$
This regex correctly matches AM=
, but not MA=
.
I don't want to list out all the possible combinations of those tokens, is there a way to do it simply?