String.RegionMatches Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
RegionMatches(Int32, String, Int32, Int32) |
Tests if two string regions are equal. |
RegionMatches(Boolean, Int32, String, Int32, Int32) |
Tests if two string regions are equal. |
RegionMatches(Int32, String, Int32, Int32)
Tests if two string regions are equal.
[Android.Runtime.Register("regionMatches", "(ILjava/lang/String;II)Z", "")]
public bool RegionMatches (int toffset, string other, int ooffset, int len);
[<Android.Runtime.Register("regionMatches", "(ILjava/lang/String;II)Z", "")>]
member this.RegionMatches : int * string * int * int -> bool
Parameters
- toffset
- Int32
the starting offset of the subregion in this string.
- other
- String
the string argument.
- ooffset
- Int32
the starting offset of the subregion in the string argument.
- len
- Int32
the number of characters to compare.
Returns
true
if the specified subregion of this string
exactly matches the specified subregion of the string argument;
false
otherwise.
- Attributes
Exceptions
if string
is null
.
Remarks
Tests if two string regions are equal.
A substring of this String
object is compared to a substring of the argument other. The result is true if these substrings represent identical character sequences. The substring of this String
object to be compared begins at index toffset
and has length len
. The substring of other to be compared begins at index ooffset
and has length len
. The result is false
if and only if at least one of the following is true: <ul><li>toffset
is negative. <li>ooffset
is negative. <li>toffset+len
is greater than the length of this String
object. <li>ooffset+len
is greater than the length of the other argument. <li>There is some nonnegative integer k less than len
such that: this.charAt(toffset +
k) != other.charAt(ooffset +
k)
</ul>
Note that this method does <em>not</em> take locale into account. The java.text.Collator
class provides locale-sensitive comparison.
Java documentation for java.lang.String.regionMatches(int, java.lang.String, int, int)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
RegionMatches(Boolean, Int32, String, Int32, Int32)
Tests if two string regions are equal.
[Android.Runtime.Register("regionMatches", "(ZILjava/lang/String;II)Z", "")]
public bool RegionMatches (bool ignoreCase, int toffset, string other, int ooffset, int len);
[<Android.Runtime.Register("regionMatches", "(ZILjava/lang/String;II)Z", "")>]
member this.RegionMatches : bool * int * string * int * int -> bool
Parameters
- ignoreCase
- Boolean
if true
, ignore case when comparing
characters.
- toffset
- Int32
the starting offset of the subregion in this string.
- other
- String
the string argument.
- ooffset
- Int32
the starting offset of the subregion in the string argument.
- len
- Int32
the number of characters to compare.
Returns
true
if the specified subregion of this string
matches the specified subregion of the string argument;
false
otherwise. Whether the matching is exact
or case insensitive depends on the ignoreCase
argument.
- Attributes
Exceptions
if string
is null
.
Remarks
Tests if two string regions are equal.
A substring of this String
object is compared to a substring of the argument other
. The result is true
if these substrings represent character sequences that are the same, ignoring case if and only if ignoreCase
is true. The substring of this String
object to be compared begins at index toffset
and has length len
. The substring of other
to be compared begins at index ooffset
and has length len
. The result is false
if and only if at least one of the following is true: <ul><li>toffset
is negative. <li>ooffset
is negative. <li>toffset+len
is greater than the length of this String
object. <li>ooffset+len
is greater than the length of the other argument. <li>ignoreCase
is false
and there is some nonnegative integer k less than len
such that: <blockquote>
this.charAt(toffset+k) != other.charAt(ooffset+k)
</blockquote> <li>ignoreCase
is true
and there is some nonnegative integer k less than len
such that: <blockquote>
Character.toLowerCase(Character.toUpperCase(this.charAt(toffset+k))) !=
Character.toLowerCase(Character.toUpperCase(other.charAt(ooffset+k)))
</blockquote> </ul>
Note that this method does <em>not</em> take locale into account, and will result in unsatisfactory results for certain locales when ignoreCase
is true
. The java.text.Collator
class provides locale-sensitive comparison.
Java documentation for java.lang.String.regionMatches(boolean, int, java.lang.String, int, int)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.