Java doesn't work with regex \s, says: invalid escape sequence
You need to escape the slash
start_from = start_from.replaceAll("\\s", "+");
The problem is that \
is an escape character in java as well as regex patterns. If you want to match the regex pattern \n
, say, and you'd go ahead and write
replaceAll("\n", "+");
The regex pattern would not end up being \n
: it would en up being an actual newline, since that's what "\n"
means in Java. If you want the pattern to contain a backslash, you'll need to make sure you escape that backslash, so that it is not treated as a special character within the string.
replaceAll("\\s", "+");