Lets say I need to match a word word where there may be a period before word or after word but not both. Then word, .word, and word. should be matched, but .word. should not be matched. How would I match this and capture what occurred before and after the word?
That was a simplified example that I'll need to extend to more complicated cases. For example, now the symbols . and ' may occur before or after the word, but they can only occur once. So for example, .word, 'word, word.', and .word' are just a few of the valid matches, but something like .'word.' shouldn't match, or even .'word'.
The above example is my main priority, but an added bonus would be the order in which the period and apostrophe are added. Thus '.word and .'word should both match. I think one way that should work for this is \.?'?|'?\.?word, but I was hoping for some way where the number of statements in the OR clause doesn't depend on the number of symbols.