Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abaxial van osovine
- abbacy opatstvo
- abbaino kora
- abbatial opatski
- abbe opat
- abbé opat
- abbé sveæenik
- String text = "abbacy opatstvo";
- System.out.println(text.substring(text.lastIndexOf(" ")+1));
- hematological parameters hematološki pokazatelji
- /**
- * 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"));
- }
- .+ {2,}
- yourString.replaceAll(".+ {2,}", "");
Add Comment
Please, Sign In to add comment