Try \w+ ?\+ ?\w+
. It uses the ?
quantifier which makes matching the previous token optional.
If there could be more than one space, you could try \w+ *\+ *\w+
, since *
matches the previous token between zero and unlimited times.
solved what’s the regex to identify a “string” + ” string”?