Please point me to a post if one already exists for this question.
How might I efficiently add in word boundary syntax to list of strings?
So for instance, I want to make sure the words below in badpositions
only match a word in their entirety so I'd like to use re.search('\bword\b', text)
.
How do I get the words in bad positions to take the form ['\bPresident\b', '\bProvost\b']
etc
text = ['said Duke University President Richard H. Brodhead. "Our faculty look forward']
badpositions = ['President', 'Provost', 'University President', 'Senior Vice President']