I’m looking for a single line regular expression which matches a pattern with optional parentheses. When the parentheses are present they should not be included in the matched pattern.
The following bold text demonstrates what should / shouldn’t match:
Should Match:
“Title Description (AAA123)”
“(ABC000) Title Description”
“Title Description DEF999“
“Title – RST321 – Description”
Shouldn’t Match:
“Title Description AB123”
“Title Description CCC456a”
“Title Description (ABE999c)”
Try this regex:
This matches:
The regex doesn’t care about parentheses, like requested, but doesn’t match strings that are too long.