Java String.replace()
メソッドregionMatches()は、2つのString領域が等しいかどうかをチェックします。
以下にいくつかの重要なポイントを示します。
-
ignoreCaseは、両方のStringsの場合を無視するかどうかを指定します
-
toffsetは、最初のStringの開始インデックスを決定します
-
otherは、2番目のStringを指定します。
-
ooffsetは、2番目のStringの開始インデックスを指定します
-
lenは、比較する文字数を指定します
利用可能な署名
public boolean regionMatches(int toffset, String other, int ooffset, int len)
boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)
例
@Test
public void whenCallRegionMatches_thenCorrect() {
assertTrue("welcome to example".regionMatches(false, 11, "example", 0, 8));
}