Java String.regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)

Syntax

String.regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) has the following syntax.

public boolean regionMatches(boolean ignoreCase,   int toffset,   String other,   int ooffset,   int len)

Example

In the following code shows how to use String.regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) method.


/*from   w  ww  .  j  a  va2 s. co m*/

public class Main {

  public static void main(String[] args) {
  
    String str1 = "tutorials from java2s.com";
    String str2 = "Java tutorials from java2s.com";

    
    str2 = "Consists of different Tutorials";
    boolean match1 = str1.regionMatches(true, 14, str2, 22, 10); 
    System.out.println("region matched = " + match1);   
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable