数字与字母分割
public class Main{ public static void main(String args[]){ String s="ahkjdfnajk321anbkjdfbnjakfdkja4213746187"; s=s+"."; int n=s.length(); char a[]=new char[n]; a=s.toCharArray(); int start=-1; int end=-1; for(int i=1;i<n;i++){ if(a[i]>=48 && a[i]<=57 && (a[i-1] < 48 || a[i-1] > 57)){ a[i-1]='^'; } if(a[i]>=48 && a[i]<=57 && (a[i+1] < 48 || a[i+1] > 57)){ a[i+1]='^'; } } s=String.valueOf(a); String aa[]=s.split("\\^"); for (int i = 0 ; i <aa.length ; i++ ){ System.out.println("--"+aa[i]); } } }