So you could use regex to do the string manipulated pretty efficently.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
/**
* Splits the line related to translation into 2 groups by splitting it on
* two spaces " " and storing the splits into two named groups (key,
* value)</br>
* Group1 (key) is the text before the two spaces.</br>
* Group2 (value) is the text after the two spaces.</br>
*/
private static final Pattern TRANSLATION_PATTERN = Pattern.compile("<key>.*)\\s\\s+(<value>.*)");
public static String grabTextAfterTwoSpaces(String input) {
Matcher matcher = TRANSLATION_PATTERN.matcher(input);
/*
* You have to call .matches() for the regex to actually be applied.
*/
if (!matcher.matches()) {
throw new IllegalArgumentException(String.format("Provided input:[%s] did not contain two spaces", input));
}
return matcher.group("value");
}
public static void main(String[] args) {
System.out.println(grabTextAfterTwoSpaces("abaxial van osovine"));
System.out.println(grabTextAfterTwoSpaces("abbacy opatstvo"));
System.out.println(grabTextAfterTwoSpaces("abbaino kora"));
System.out.println(grabTextAfterTwoSpaces("abbatial opatski"));
System.out.println(grabTextAfterTwoSpaces("abbe opat"));
System.out.println(grabTextAfterTwoSpaces("abbé opat"));
System.out.println(grabTextAfterTwoSpaces("abbé sveæenik"));
System.out.println(grabTextAfterTwoSpaces("abbacy opatstvo"));
System.out.println(grabTextAfterTwoSpaces("hematological parameters hematološki pokazatelji"));
}
}
Try it online!
So if you use "value" for the group you'll get everything after the 2+ spaces.
osovine
opatstvo
kora
opatski
opat
opat
sveæenik
opatstvo
hematološki pokazatelji