I'm trying to match the local part of an email address before the @ character with:
LOCAL_RE_NOTQUOTED = """
((
\w # alphanumeric and _
| [!#$%&'*+-/=?^_`{|}~] # special chars, but no dot at beginning
)
(
\w # alphanumeric and _
| [!#$%&'*+-/=?^_`{|}~] # special characters
| ([.](?![.])) # negative lookahead to avoid pairs of dots.
)*)
(?<!\.)(?:@) # no end with dot before @
"""
Testing with:
re.match(LOCAL_RE_NOTQUOTED, "a.a..a@", re.VERBOSE).group()
gives:
'a.a..a@'
Why is the @
printed in the output, even though I'm using a non-capturing group (?:@)
?
Testing with:
re.match(LOCAL_RE_NOTQUOTED, "a.a..a@", re.VERBOSE).groups()
gives:
('a.a..a', 'a', 'a', None)
Why does the regex not reject the string with a pair of dots '..'
?