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

vikas pal
vikas pal
10,413 Points

why we use this'-' in [-\w ]?

please tell me why we used '-' this in [-\w ] to find first name .what it mean and what to tells to python

1 Answer

Jeffrey Huther
seal-mask
.a{fill-rule:evenodd;}techdegree
Jeffrey Huther
Python Web Development Techdegree Student 4,175 Points

From what I understand, the "-" in [-\w ] means look for hyphen. For example, You will need the "-" to find the 1st name: Sven-Erik. If you just use [\w ], the search will not return Sven-Erik. Hopefully this helps

vikas pal
vikas pal
10,413 Points

thank you to reply fast and clearing my doubt easily.Thaaaaaaaaaaaaaaank yoooooooooooooooooou