354-11 Why did it catch "mails" without \b before "e"?

Before I got to the right answer (adding \b at the beginning and the end), the following regex pattern caught more than the expected matches,such as row 450 of the “titles” dataset which contains the word “Mails”.

r'e[ -]{,1}mails?'

Why did it skip the “e” as optional when searching?

Hi @cmpriscilla,

concerning the question:

I tested this with regex101 and did not catch the “Mails”, only “email”, “e mail” and “e-mail”.

Could you post the link to the mission?

Sure! Here is the link to the mission.

Below is the code I used and an example result that I got

@cmpriscilla

Thanks!

So, in the end you got it right. The pattern:

pattern = r'e[ -]{,1}mails?'

worked and got all instances of email. In the case of titles[450] it’s this part:
Mailtrain (the open source Mailchimp clone) is getting automation support

And to fix this, as you pointed out, \b must be added in the beginning of the expression.

1 Like

Oh my! My apologies for missing that.
Thank you for the anwer :slight_smile:

1 Like