Answers for "how to cut a string in java"

0

how to cut a certion part from a string in java

int startIndex = str.indexOf("(");
int endIndex = str.indexOf(")");
String replacement = "I AM JUST A REPLACEMENT";
String toBeReplaced = str.substring(startIndex + 1, endIndex);
System.out.println(str.replace(toBeReplaced, replacement));
Posted by: Guest on June-24-2020
0

how to cut a certion part from a string in java

String str = "manchester united (with nice players)";
System.out.println(str.replace("(with nice players)", ""));
int index = str.indexOf("(");
System.out.println(str.substring(0, index));
Posted by: Guest on June-24-2020

Code answers related to "how to cut a string in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language