数字与字母分割+
1 public class Main{ 2 public static void main(String args[]){ 3 String s="ahkjdfnajk321anbkjdfbnjakfdkja4213746187"; 4 s=s+"."; 5 int n=s.length(); 6 char a[]=new char[n]; 7 a=s.toCharArray(); 8 int start=-1; 9 int end=-1; 10 for(int i=1;i<n;i++){ 11 if(a[i]>=48 && a[i]<=57 && (a[i-1] < 48 || a[i-1] > 57)){ 12 a[i-1]='^'; 13 } 14 if(a[i]>=48 && a[i]<=57 && (a[i+1] < 48 || a[i+1] > 57)){ 15 a[i+1]='^'; 16 } 17 } 18 s=String.valueOf(a); 19 String aa[]=s.split("\\^"); 20 int count[]=new int[aa.length]; 21 for (int i = 0 ; i <aa.length ; i++ ){ 22 int nn=aa[i].length(); 23 char aaa[]=new char[nn]; 24 aaa=aa[i].toCharArray(); 25 for(int j=0;j<nn;j++){ 26 if(aaa[j]>=48 && aaa[j]<=57){ 27 count[i]++; 28 } 29 } 30 } 31 String ss=null; 32 for(int i=0;i<aa.length;i++){ 33 if(count[i]>6){ 34 ss=aa[i]; 35 } 36 } 37 System.out.println(ss); 38 } 39 }