Reputation: 15103
is it possible to capture only multiple characters within 'or'?
i would like this [(abc)(cde)]
to capture abc or cde
however it captures ( or a or b or c or ) ...
i saw this: regular-expression-capture-groups-which-is-in-a-group
is what i'm asking not possible in regular expressions? it sounds too obvious and far needed, for me not to exist in it...
Upvotes: 1
Views: 123
Reputation: 336148
You want this:
(abc|cde)
This matches either abc
or cde
and captures the result in a backreference. If you don't need the backreference, use
(?:abc|cde)
Another hint: If you want to make sure that you only match entire words, not substrings within a longer word like abc
within tabcontrol
, use word boundaries:
\b(abc|cde)\b
Upvotes: 4