추출월

727 단어
package regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class tiquMonth {
	public static void main(String[] args) {
		String regEx="([a-zA-Z]+)\\s+[0-9]{1,2},\\s*[0-9]{4}";
		String str="June 26, 1951";
		Pattern p=Pattern.compile(regEx);
		Matcher m=p.matcher(str);
		
		while(!m.find()){
			System.out.println("      !");
			return;
			
		}
		
		System.out.println(m.group(1));
		System.out.println(m.group(0));
//		System.out.println(m.group(2));
	}

}

 
수행 결과는 다음과 같습니다.
 JuneJune 26, 1951

좋은 웹페이지 즐겨찾기