I'm trying to use re.findall() find all the occurrences of the names of weekdays. It works when I exclude the \b
, but not when I include them. This works:
any_week_day_long = "([Mm]onday|[Tt]uesday|[Ww]ednesday|[Tt]hursday|[Ff]riday|[Ss]aturday|[Ss]unday)"
match = re.findall(any_week_day_long, "Monday is a great day of the week. Tuesday is pretty good, but Wednesday has it beat.")
but this does not:
any_week_day_long = "\b([Mm]onday|[Tt]uesday|[Ww]ednesday|[Tt]hursday|[Ff]riday|[Ss]aturday|[Ss]unday)\b"
match = re.findall(any_week_day_long, "Monday is a great day of the week. Tuesday is pretty good, but Wednesday has it beat.")
It seems to me like it should find Monday, Tuesday, and Wednesday just fine with the \b
, but when I print
match, it's just an empty list.