String lines =
"[no=1, position=batter, name=lee, birth=1900-**-11, age=36, " +
"height=175.0, batcount=3, hit=3, hitAvg=3.0] " +
"[no=2, position=pitcher, name=cho, birth=1955-**-14, age=27, " +
"height=180.2, win=4, lose=4, defense=4.0] " +
"[no=3, position=batter, name=kim, birth=1999-**-14, age=20, " +
"height=155.0, batcount=2, hit=3, hitAvg=7.0] ";
Matcher m = Pattern.compile( "(w+)=(S*)[,]]" ).matcher( lines );
while( m.find() )
{
if( m.group( 1 ).equals( "no" ) )
System.out.println( "" );
System.out.println( m.group( 1 ) + " : " + m.group( 2 ) );
}
출력.
no : 1
position : batter
name : lee
birth : 1900-**-11
age : 36
height : 175.0
batcount : 3
hit : 3
hitAvg : 3.0
no : 2
position : pitcher
name : cho
birth : 1955-**-14
age : 27
height : 180.2
win : 4
lose : 4
defense : 4.0
no : 3
position : batter
name : kim
birth : 1999-**-14
age : 20
height : 155.0
batcount : 2
hit : 3
hitAvg : 7.0
정규표현식 잘 안 외워지던데ㅠㅠ - dc App
나도 하루 공부해서 C++ 소스코드 하이라이팅 한 번 만들어 본게 전부.