Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Main
- {
- private String str(){
- String str="00!!!0* dsgsh235 !!!=-lktrfgho";
- Pattern r = Pattern.compile("[-[0-9]_!@#$%&*()+=\s+]");
- Matcher b = r.matcher(str);
- Pattern pat = Pattern.compile("[A-Z+][a-z+]");
- Matcher mat = pat.matcher(str);
- return str;
- }
- public static void main(String[] args)
- {
- String str="00!!!0*dAsgsh235 !!!=-lktKHrfgho";
- Pattern pat = Pattern.compile("[^(A-Za-z)]+");
- Matcher mat = pat.matcher(str);
- while (mat.find()) System.out.print(mat.group());
- }
- }
- Pattern pattern = Pattern.compile("[^a-zA-Z]+");
- Matcher matcher = pattern.matcher("asd2$%*^$^#22l######khlh4444lklkb!!!!!!!");
- int maxLenght = 0;
- while (matcher.find()){
- int lenght = matcher.group().length();
- // System.out.println(matcher.group()); // debug
- if (lenght > maxLenght) maxLenght = lenght;
- }
- System.out.println(maxLenght);
Add Comment
Please, Sign In to add comment