Welcome to the Treehouse Community
Looking to learn something new?
nicole lumpkinCourses Plus Student 5,328 Points
Using the + character at the end of a set
This has really been bugging me. It was my understanding that the + character when used after a set means any character within the set must appear at lease once. My question is why does the following pattern match my email variable(defined below) even though the '+' character, amongst others, is not present in the string?
email = 'email@example.com' print(re.findall(r'[-\w\d+.]+@[-\w\d.]+', email, re.I)) >>>['firstname.lastname@example.org']
Why does this work(match)?? There are no digits, hyphens, or plus characters in 'email'.
Steven Parker215,940 Points
The plus character itself is not actually part of the allowed/required set.
The regex "
[-\w\d.]+" means "at least one hyphen, "word character", digit, or period". The digit (\d) metacharacter is actually not needed here since a "word character" (\w) can be any alpha-numeric character or