One way would be to write:
^((electric|acoustic) (guitar|drums)|(electric|acoustic|guitar|drums))$
or (because you don't need parentheses to write)
^(?:(?:electric|acoustic) (?:guitar|drums)|(?:electric|acoustic|guitar|drums))$
You can also use the trick if you don't like repeating:
^(?:electric()|acoustic())? ?(?:guitar()|drums())?(?:\1|\2|\3|\4)$
(?:\1|\2|\3|\4) ensures that at least one of the previous empty capture groups ( () ) participated in the match.
source share