Forum Moderators: phranque
I'm trying to extract complete swear words from a string, which may be at the beginning, middle or end of the string (i.e possibly followed by a space) without affecting the surrounding non-swear words.
For example, imagine "widget" is a swear word. My string might be 'widget book' or 'widgeting' or 'jolly good widgets' etc.
So I'm trying to match 'widget' possibly followed by more characters and then possibly followed by a space.
I've tried a number of different combinations but either end up selecting the whole word plus the following (non-swear) words or just the base word without the following characters.
I like regex but it has a habit of driving me insane. Any help most appreciated.
Thanks
Stretch