java 1.4 버전 이상에서 사용 가능합니다.
/*
s2 의 문자열이 "소토로" 로 끝나는지 검사합니다.
s1 에서 ".*" 는 어떤 문자열이 와도 좋다는 것을 의미합니다.
s1 에서 마지막 "$" 는 문장의 끝을 의미합니다.
*/
import java.util.regex.*;
public class PatternTest2
{
public static void main(String[] args)
{
String s1 = ".*소토로$";
String s2 = "123소토로";
Pattern p = Pattern.compile(s1);
Matcher m = p.matcher(s2);
boolean b = m.matches();
System.out.println(b);
b = Pattern.matches(s1, s2);
System.out.println(b);
}
}