The question is:
Write a function
untilSpace(s)
that returns a substring ofs
starting at the beginning and extending until a space is found. The space is not included in the returned value. The argument will always have a space.
Examples:
untilSpace("ab cde") -> "ab"
My code solution is:
public String untilSpace(String s){
String str = s;
str = str.replaceFirst(" ", "");
System.out.println(str);
return str;
}
I managed to remove the space, but I still need to find a way to remove the rest of the string that comes after the space.