how to cut a certion part from a string in java

Solutions on MaxInterview for how to cut a certion part from a string in java by the best coders in the world

showing results for - "how to cut a certion part from a string in java"
Martina
26 Jan 2016
1int startIndex = str.indexOf("(");
2int endIndex = str.indexOf(")");
3String replacement = "I AM JUST A REPLACEMENT";
4String toBeReplaced = str.substring(startIndex + 1, endIndex);
5System.out.println(str.replace(toBeReplaced, replacement));
Neila
25 Mar 2016
1str2=str.substring(begin, [end]) 
Francesco
21 Feb 2020
1String str = "manchester united (with nice players)";
2System.out.println(str.replace("(with nice players)", ""));
3int index = str.indexOf("(");
4System.out.println(str.substring(0, index));