"String".matches [1]

正規表現を利用して適切な文字列かどうか真偽する。ユーザによる入力データが適切かどうかの判断などに利用できる。

String s1 = "Java and Python and C++.";
if (s1.matches("^[Jj]ava.*")) {
   System.out.println("ture");
}

//endsWith(), startsWithの代用
s1.matches("Ma.*");
s1.matches(.*ful");