Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJosu Gurtubay
1,011 PointsDiference between [\\s+] and \\s+
Hi,
which is the difference between:
public String[] getWords(){ return mBody.split(" [\s+]"); }
and
public String[] getWords(){ return mBody.split("\s+"); }
as in the video Craig added []...
regards
3 Answers
Peter Price
4,007 PointsHi ,
The two lines in question are exactly the same. Could you change them so that it is easier to understand what you are asking.
Peter Price
4,007 PointsHi Josu,
Never mind you typed it correctly in the title. I believe that these [] separate \s+ from the quotation marks.
Josu Gurtubay
1,011 PointsWhy in the video its with [] and in the challenge its without []
Peter Price
4,007 PointsHi Josu,
I went back to the challenge and I couldn't get it to work without the [] (two brackets). Could you show me your code when you did it WITHOUT the two brackets using Markdown Cheatsheet (located underneath the add an answer box). That would be helpful so that I can visualize how your code looks without.
Thanks