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.

Python Regular Expressions in Python Introduction to Regular Expressions Groups


What is the point of having a hyphen in front of \w, when the last names and first names don't contain a hyphen

1 Answer

Christian Beckett
Christian Beckett
11,121 Points

the python syntax requires it that way python registers the \w with a hyphen as a categorizing tool. this is what i imagine your confused about [-\w] the reason this is used so that you may find the first name as well. say like this. when you try using this \w you'll find this for my name ChristianBeckett but when you use this -\w you find Christian-Beckett i will admit the explanation for this can be kind of confusing jayda hendrickson