I have a list of strings. Some of them are of the form 123-...456. The variable portion \"...\" may be:
123-...456
Try:
123-(?:(apple|banana|)-|)456
That will match apple, banana, or a blank string, and following it there will be a 0 or 1 hyphens. I was wrong about not having a need for a capturing group. Silly me.
apple
banana