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 trial

Java Java Data Structures - Retired Organizing Data Splitting Strings

samuel bailey
samuel bailey
6,911 Points

illegal escape character???

public String[] getWords() { return = mBody.split("\s+"); }

2 Answers

deckey
deckey
14,630 Points

Hi Samuel, interpreter is reading \s as an escape character, which does not exist.

What you need to do is tell it to ignore the backslash by adding one more, with \\s

Oh, and there is no = for return statements, good luck!

Seth Kroger
Seth Kroger
56,413 Points

Because Java strings use \ as an escape sequence for special characters in strings every time you need to use a \ in a regex you need to double it: \