Guest User

Untitled

a guest
Dec 17th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. abaxial van osovine
  2. abbacy opatstvo
  3. abbaino kora
  4. abbatial opatski
  5. abbe opat
  6. abbé opat
  7. abbé sveæenik
  8.  
  9. String text = "abbacy opatstvo";
  10. System.out.println(text.substring(text.lastIndexOf(" ")+1));
  11.  
  12. hematological parameters hematološki pokazatelji
  13.  
  14. /**
  15. * Splits the line related to translation into 2 groups by splitting it on
  16. * two spaces " " and storing the splits into two named groups (key,
  17. * value)</br>
  18. * Group1 (key) is the text before the two spaces.</br>
  19. * Group2 (value) is the text after the two spaces.</br>
  20. */
  21. private static final Pattern TRANSLATION_PATTERN = Pattern.compile("<key>.*)\s\s+(<value>.*)");
  22.  
  23. public static String grabTextAfterTwoSpaces(String input) {
  24. Matcher matcher = TRANSLATION_PATTERN.matcher(input);
  25.  
  26. /*
  27. * You have to call .matches() for the regex to actually be applied.
  28. */
  29. if (!matcher.matches()) {
  30. throw new IllegalArgumentException(String.format("Provided input:[%s] did not contain two spaces", input));
  31. }
  32.  
  33. return matcher.group("value");
  34. }
  35.  
  36. public static void main(String[] args) {
  37. System.out.println(grabTextAfterTwoSpaces("abaxial van osovine"));
  38. System.out.println(grabTextAfterTwoSpaces("abbacy opatstvo"));
  39. System.out.println(grabTextAfterTwoSpaces("abbaino kora"));
  40. System.out.println(grabTextAfterTwoSpaces("abbatial opatski"));
  41. System.out.println(grabTextAfterTwoSpaces("abbe opat"));
  42. System.out.println(grabTextAfterTwoSpaces("abbé opat"));
  43. System.out.println(grabTextAfterTwoSpaces("abbé sveæenik"));
  44. System.out.println(grabTextAfterTwoSpaces("abbacy opatstvo"));
  45.  
  46. System.out.println(grabTextAfterTwoSpaces("hematological parameters hematološki pokazatelji"));
  47. }
  48.  
  49. .+ {2,}
  50.  
  51. yourString.replaceAll(".+ {2,}", "");
Add Comment
Please, Sign In to add comment