Basic regular expression Ex 12

Hi everyone,

The code I wrote to find all the different variations of email is:

“^(?i)e[- ]?mail|(?i)e[- ]?mail$|(?i)e[- ]?mail”

And Dataquest’s answer is: “(?i)e[\-\s]?mail”

Is my code overly complicated?

So here’s the weird thing, mine was overly simplistic (pattern <- “(?i)e ?-?mail”) but it still got the same result.
Did you get the proper count with your version?

I don’t think you need the ^ or $. They just wanted email mentions in general, your answer would find them at the beginning and end of the title specifically and then anywhere in general. What I do think you need to account for is both the possibility of the hyphen AND the possibility of the space.
In their solution of pattern <- “(?i)e[\-\s]?mail”, the [\-\s] means hyphen or whitespace and then the question mark makes them optional. I don’t know if that helps at all.