I am currently testing a string to be in a specific mail format.
/^[A-Za-z0-9](([A-Za-z0-9]|\.(?!\.))*[A-Za-z0-9]+)?@[A-Za-z0-9]+\.[A-Za-z]{2,}$/.test(email)
Now I have some parenthesis which could be marked as non-capturing groups like this:
/^[A-Za-z0-9](?:(?:[A-Za-z0-9]|\.(?!\.))*[A-Za-z0-9]+)?@[A-Za-z0-9]+\.[A-Za-z]{2,}$/.test(email)
But I don't see any difference between the results. Tests only checks, so it should be irrelevant, shouldn't it?
Switching between capturing and noncapturing groups in test is relevant only if you use backreferences (
\1
\2
). As you don't, the change has no effect.