Is there some way to write this simple regular expression more concisely? (here I am using separate lines to improve readability, even though I normally wouldn't use them)

(
(regex (matches|corresponds to) string)
|
(string (matches|corresponds to) regex)
)

"string" and "regex" are switched around here, and I want to express this concisely. I want to avoid writing (matches|corresponds to) more than once.

link|improve this question

20% accept rate
It depends on the flavor--if any. Not with POSIX, maybe with PCRE, but I'm not sure. It's hard to think of a meta language that saves you the work, and yet is restricted to regular languages. – artistoex Jan 28 at 8:18
I'm using Javascript's regex engine. – Anderson Green Jan 28 at 16:23
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.