[Tutor] How to find a word in a string - nearly correct

Phil phillor9 at gmail.com
Mon May 3 22:09:42 EDT 2021


On 4/5/21 11:20 am, Mats Wichmann wrote:
> On 5/3/21 7:09 PM, Phil wrote:
import re

result = re.search(r'\b' + 'this' + '\W', test)

print(result.group())

The output is 'this,' ,which is based on a white-space between words 
rather than punctuation. The search continues.

-- 
Regards,
Phil



More information about the Tutor mailing list