I know one of the regular expression is "\s+" which is mean one or more whitespaces. But in many referenece that I saw,
Why they use double backslash "\\s+" instead of just one backslash "\s+" ?
For exemple in this code that I get in stackoverflow :
import java.math.*;
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Initials {
public String getInitials(String s) {
String r = "";
for(String t:s.split("\\s+")){
r += t.charAt(0);
}
return r;
}
void p(Object... o) {
System.out.println(deepToString(o));
}
}
And the output from this code is :
Example Input: "john fitzgerald kennedy"
Returns: "jfk"