文字列に文字と数値を含める方法を分割します.

1015 ワード

HR 4 Fを
非常hr 4 fに変換

public class SplitString {
	private String str="HR4F";
	public void tochar()
	{
		//                 
		String num="";
		String temp="";
		char[] dst=new char[str.length()];
		//           
		str.getChars(0, str.length(), dst, 0);
		//              
		for(int i=0;i<dst.length;i++)
		{
			//0~9   ASCII      48~57
			//        ,            num
			if((dst[i]>=48)&&(dst[i]<=57))
			{
				num+=String.valueOf(dst[i]);
			}
			else
			{
				//          
				temp=String.valueOf(dst[i]);
				//               num    
				num+=temp.toLowerCase();
			}
		}
		System.out.println(num);
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		SplitString sp=new SplitString();
		sp.tochar();
	}

}