Scala 字符串 regionMatches(int toffset, String other, int offset, int len)方法实例
regionMatches(int toffset, String other, int offset, int len) 方法用于检查两个字符串区域是否相等。但是,这里不包括ignoreCase。
方法定义。Boolean regionMatches(int toffset, String other, int offset, int len)
返回类型。如果两个字符串区域匹配,返回true,否则返回false。
例子 #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
极客教程