編集の要約なし
編集の要約なし
2行目: 2行目:
public boolean matches(String regex)
public boolean matches(String regex)


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


  if (s.matches("ho[gbw]e")) {
  if (s.matches("ho[gbw]e")) {
     System.out.println("It matches!");
     System.out.println("It matches!");
  }
  }

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

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

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

if (s.matches("ho[gbw]e")) {
    System.out.println("It matches!");
}