Daniel Holler Daniel Holler - 8 months ago 15
Java Question

Remove everything in a string after a second space if there is one

Lets say I have this text:

Thundering Blow I
. What I need is something that makes it look like
Thundering Blow
- Removing the roman number at the end of the string.

I have tried
and some
methods but they all keep returning:
Thundering Blow I
back to me. Maybe it could remove everything after a
in the string? Would also be fine, but I cant seem to find a way to fix it.


You need this, removes all characters after second space

String s = "Thundering Blow I";
int k = s.indexOf(" ", s.indexOf(" ") + 1);
String res = s.substring(0,k);