Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Ryan Fadholi5,168 Points
Why the + sign in the set doesn't have to be escaped?
Hi, I'm under the impression that if I want to match anything that is an operator in regex I need to escape it using '\', for example when we was looking for the '(' the \ is added before the (.
So, any reason why the + sign inside the set in the email regex isn't escaped and it still works?
James J. McCombiePython Web Development Techdegree Graduate 21,137 Points
do you mean something like this:
if you were trying to match dates in the format dd/dd/yyyy for example (I do not know precisely what part of Kenneth's tutorial you are referring to, so I am making my own example).
you have to use the \ to escape special characters, these include the ( and ) because these define capturing groups in a regex search and will be treated as such if you do not escape them. the + is a special character in regex, it is a quantifier telling the module to look for one or more instances of what comes before it, in the example above it says look for groups of one or more digits. if you escaped it with +, the program would look for + in the thing you are searching through.