Regex Working On Regexpal But Not With Python
I am trying to write a regex to catch email Ids . Testing since quite a few hours using regexpal.com . On the site, its able to catch all the email Ids. WHen I am substituting the
Solution 1:
Read the documentation for re.findall:
If one or more groups are present in the pattern, return a list of groups
Your groups only capture the at sign, dot, etc., therefore that's all that's returned by re.findall. Either use non-capturing groups, wrap the whole thing in a group, or use re.finditer.
(As noted by @Igor Chubin, your regex is also incorrectly using . instead of \., but this isn't causing the main problem.)
Solution 2:
You must use \. not . here:
(.|dot)
If you just want to say that you can have hyphens between letters
in the edu part, you can do this without slashes and grouping:
e-?d-?u-?[.,]?
If you use () just to group symbols (but not for capturing),
you must use (?:)instead:
(?:@|at)
Post a Comment for "Regex Working On Regexpal But Not With Python"