Trying to Understand some RegEx differences 369/7

Link to exercise: https://app.dataquest.io/m/369/advanced-regular-expressions/7/substituting-regular-expression-matches

So, I struggled with getting “e Mail” and “e mail” to match with my original go at the regex pattern.

pat = r"e[-]?[/s]?mail"

The above seemed like it should work but wasn’t. I change it to:

pat = r"e[-]? ?mail"

This worked and yielded a pass on the mission but I am struggling to understand why the latter worked and the former did not. Insights appreciated!

Hi Clara. In your pattern, you have [/s]. Did you mean [\s]?

1 Like

I had thought I’d had [\s] (and mistyped on here) but I did not keep my failed pattern after passing through the exercise. Perhaps I had the slash incorrect and that was my struggle, utilizing backslash also resulted in a correct answer on the exercise. Thanks for pointing this out!