📜  Scala String regionMatches(int toffset, String other, int offset, int len) 方法示例

📅  最后修改于: 2022-05-13 01:54:51.642000             🧑  作者: Mango

Scala String regionMatches(int toffset, String other, int offset, int len) 方法示例

regionMatches(int toffset, String other, int offset, int len)方法用于检查两个字符串区域是否相等。但是,这里不包括ignoreCase

示例 #1:

// Scala program of int regionMatches()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying regionMatches method
        val result = "Preeti".regionMatches(0, "Preeti", 0, 4)
          
        // Displays output
        println(result)
      
    }
} 
输出:
true

示例 #2:

// Scala program of int regionMatches()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying regionMatches method
        val result = "Preeti".regionMatches(0, "pReeti", 0, 4)
          
        // Displays output
        println(result)
      
    }
} 
输出:
false