http://levin01.tistory.com/285

public class Test2 {

public static void main(String[] args) {
String str="한글12 this i8s english 입2니3다.";
int k=0;
int e=0;
int d=0;
int z=0;
for(int i=0;i<str.length();i++){
char c=str.charAt(i);
//한글 ( 한글자 || 자음 , 모음 )
if( ( 0xAC00 <= c && c <= 0xD7A3 ) || ( 0x3131 <= c && c <= 0x318E ) ){
System.out.println("k"+c);
k++;
}else if( ( 0x61 <= c && c <= 0x7A ) || ( 0x41 <= c && c <= 0x5A ) ){
//영어
System.out.println("e:"+c);
e++;
}else if( 0x30 <= c && c <= 0x39 ){
//숫자
System.out.println("d"+c);
d++;
}else{
System.out.println("z"+c);
z=0;
}
}

System.out.println("-------결과--------");
System.out.println("한글:"+k);
System.out.println("영어:"+e);
System.out.println("숫자:"+d);
System.out.println("그외:"+z);
System.out.println("계:"+(k+e+d+z));
}
}

----------

k한
k글
d1
d2
z
e:t
e:h
e:i
e:s
z
e:i
d8
e:s
z
e:e
e:n
e:g
e:l
e:i
e:s
e:h
z
k입
d2
k니
d3
k다
z.
-------결과--------
한글:5
영어:13
숫자:5
그외:0
계:23

'Jop Tip' 카테고리의 다른 글

ime-mode  (1) 2011.08.02
HTTP 1.1 status codes  (0) 2010.09.16
w i n d o w s 7  (2) 2010.07.16
카운트 다운 js  (0) 2010.06.03
jvm terminated 와 함께 eclipse가 비정상종료되는 에러!!!  (0) 2006.12.28
Posted by omok
,