Yes, that's certainly possible, but you will have to check which capturing groups matched:
/^(?:(\d\d)-([a-z]{3})-(\d{4})|([a-z]{3})-(\d\d)-(\d{4}))$/i
If groups 1
through 3
are defined after the match, then dd-MMM-yyyy
was used, if groups 4
through 6
are defined, then the other was used.
This regex doesn't do any plausibility checking, so it would match 99-XXX-9999
as well, but that's a different problem.