I am trying to find all instances of some words, but only if they have a space on either side.
So for example, if I have the text " Word1 Word2 " I want to match both Word1 and Word2. However, the Word1 match includes the space after it, so Word2 is not counting it as a preceding space.
This is my Regex: (?: )(Word1|Word2)(?: )
Is there a way to re-use the non-capture group characters so that both Word1 and Word2 can use the same space in their match? I do not want the space included in the match.