I'm trying to match all of the "words" with an intrusive asterisk in it, including at the beginning and the end (but no other punctuation).
For example, I'm expecting seven matches below. Instead, I got two.
text = "star *tar s*ar st*r sta* (*tar) (sta*) sta*."
p = re.compile(r"\b\w*\*+\w*\b")
p.findall(text) # ['s*ar', 'st*r']
# Expected ['*tar', 's*ar', 'st*r', 'sta*', '*tar', 'sta*', 'sta*']
I understand that the reason is the asterisk is not considered part of a word bounded by the \b
meta-character, but after reading all of Python's How-to, I still don't quite know how to get what I want.