It’s not about whether or not your answer is correct. It clearly is since it was accepted by the platform.
It’s about what edge cases your regex is accounted for vs theirs.
As you know,
 match any one character inside of them.
You are not using
, you instead use
(), but, then you use
? inside of those. And as you know,
? means you match 0 or one instances of the character before that
Both work, given the kind of inputs we have. Both of them will detect
However, if the input is
e- mail, then yours will work but DQ’s won’t. Because DQ’s will look at
- being present and then check for
space will make it assume that it’s not a match because the
 only look for either
- or the
But since you are checking for 0 or 1 instance of both
space, yours will detect it.
So, from that input’s perspective, yours is likely better a solution.
Similarly, if the input was
e -mail then neither will work. Because in your case, the order becomes a factor. Your pattern looks for
- first, and then
space comes first in the input, it ignores the
- and there’s no match.