Challenge: Using flags to Modify Regex Patterns

Screen Link:

My Code:

email_tests = pd.Series(['email', 'Email', 'e Mail', 'e mail', 'E-mail',
              'e-mail', 'eMail', 'E-Mail', 'EMAIL', 'emails', 'Emails',
              'E-Mails'])
email_titles_bool = titles.str.contains(r"\be[-]{0,1}mail\b", flags = re.I)

email_mentions = email_titles_bool.sum()

What I expected to happen:


I am suppose to get 141 for the variable, email_mentions

What actually happened:


I get 108 for the variable, email_mentions

I am stuck with how to write the regular expression. I feel like I have the right idea however
Thank you
-Salem

1 Like

Hi @salemabdulkerim,

Maybe it needs an optional ‘s’ at the end with ‘s?’ because it doesn’t match something like ‘e-mails’.

2 Likes

Maybe. I’ll try that and let you know. Thanks!
-Salem

1 Like

It worked. Thanks!
-Salem

1 Like

No worries @salemabdulkerim.