2
I can receive data like:
232321 or dwd
But sometimes a "+" can appear between the Strings. How do I extract only what comes BEFORE this character?
If so, I have an entry like "432d+321" would stay: 432d.
2
I can receive data like:
232321 or dwd
But sometimes a "+" can appear between the Strings. How do I extract only what comes BEFORE this character?
If so, I have an entry like "432d+321" would stay: 432d.
6
String str = "432d+321";
String res = str.split("\\+")[0];
// res = 432d.
Obs: for meta caracteres
, should use the '\\'
.
\ , ^ , $ , * , + , ?
5
Do so:
String str = "432d+321";
int posicao = str.indexOf('+');
if (posicao >= 0) {
str = str.substring(0, posicao);
}
System.out.println(str); // Imprime 432d
Browser other questions tagged java
You are not signed in. Login or sign up in order to post.