Guest User

Untitled

a guest
Dec 10th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. package com.company;
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4.  
  5. public class Main
  6. {
  7. private String str(){
  8. String str="00!!!0* dsgsh235 !!!=-lktrfgho";
  9. Pattern r = Pattern.compile("[-[0-9]_!@#$%&*()+=\s+]");
  10. Matcher b = r.matcher(str);
  11.  
  12. Pattern pat = Pattern.compile("[A-Z+][a-z+]");
  13. Matcher mat = pat.matcher(str);
  14. return str;
  15.  
  16. }
  17. public static void main(String[] args)
  18. {
  19. String str="00!!!0*dAsgsh235 !!!=-lktKHrfgho";
  20. Pattern pat = Pattern.compile("[^(A-Za-z)]+");
  21. Matcher mat = pat.matcher(str);
  22. while (mat.find()) System.out.print(mat.group());
  23.  
  24. }
  25.  
  26. }
  27.  
  28. Pattern pattern = Pattern.compile("[^a-zA-Z]+");
  29. Matcher matcher = pattern.matcher("asd2$%*^$^#22l######khlh4444lklkb!!!!!!!");
  30. int maxLenght = 0;
  31. while (matcher.find()){
  32. int lenght = matcher.group().length();
  33. // System.out.println(matcher.group()); // debug
  34. if (lenght > maxLenght) maxLenght = lenght;
  35. }
  36. System.out.println(maxLenght);
Add Comment
Please, Sign In to add comment