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.
Daniel Petrov3,495 Points
Is there a difference between space and \s?
Is there a difference between using space and \s in the sets and outside? In the name we use [-\w ] and in job we use [-\w\s]. Can we use just space when specifying the space between the words or only \s?
Steven Parker210,935 Points
A space just matches a space. The
\s code matches any kind of "white space", including space, tab, vertical tab, return, new line, and form feed.
Alx KiPython Web Development Techdegree Graduate 14,810 Points
Daniel Petrov, yes, \s should match almost any kind of whitespace, even letterspaces, tabs, halftabs, newlines etc. Negation 6:00 And, i guess, if you add + it will match 1x and 2x space and more: \s+