Java doesn't work with regex \s, says: invalid escape sequence

Posted by Jayomat on Stack Overflow See other posts from Stack Overflow or by Jayomat
Published on 2010-04-28T21:26:42Z Indexed on 2010/04/28 21:37 UTC
Read the original article Hit count: 447

Filed under:
|
|
|
|

hi,
I want to replace all whitespace characters in a string with a "+" and all "ß" with "ss"... it works well for "ß", but somehow eclipse won't let me use \s for a whitespace.. I tried "\t" instead, but it doesn't work either.. I get the following error:

Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \ )

this is my code:

try {
                String temp1 = from.getText().toString();
                start_from  = temp1.replaceAll("ß", "ss");
                start_from  = start_from.replaceAll("\s", "+");
                }

why doesn't it work? is it a problem with android, eclipse or what?

thanks in advance!

© Stack Overflow or respective owner

Related posts about java

Related posts about android