I have a feeling that I'm really missing something obvious here but I'm looking for a regex that will match the content of a bold tag plus the words immediatly before and after the tags.
So:
"start this string <b>is the text</b> we need end"
would match to
"string <b>is the text</b> we"
I can get to the tags and their content with <b\s*>(.*?|[^>\s]+)<\/b\s*>
but I can't seem to nail down the leading and trailing words.
Any help would be appreciated.
Try this (based on your regex):
See it on Rubular regex tester
But perhaps this would be better:
See it on Rubular regex tester