編集の要約なし
編集の要約なし
4行目: 4行目:
正規表現を利用して指定文字列と一致するか真偽します。
正規表現を利用して指定文字列と一致するか真偽します。


  if (s.matches("ho[gbw]e")) {
String s1 = "Java and Python and C++.";
    System.out.println("It matches!");
  if (s1.matches("[Jj]ava.*")) {
    System.out.println("ture");
  }
  }

2019年6月9日 (日) 13:21時点における版

"String".matches [1]
public boolean matches(String regex)

正規表現を利用して指定文字列と一致するか真偽します。

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