Enclose them in capturing parentheses, then test which sub-expression matched.
(^a$)|(^z$)|(^p$)
match_results m;
regex_match(..., m);
a -> m[1].matched
z -> m[2].matched
p -> m[3].matched
Update:
You might be able to improve on it by making a single capture group and testing the result, e.g.:
^([azp])$
...
if ('a' == m[0][0]) ...
Either method is almost certainly faster than calling regex_match
three times, though to be sure you just have to test it. Unless you're doing this really often, the difference is not worth worrying about.
Obviously, make sure that you're only setting up the regex once, not each time you need it.
If need it to be really, really fast you probably shouldn't be using a regex.