Java Utililty Methods String Match

List of utility methods to do String Match

Description

The list of methods to do String Match are organized into topic(s).

Method

booleanregionMatches(boolean ignoreCase, CharSequence thisSeq, int toffset, CharSequence otherSeq, int ooffset, int len)
region Matches
int to = toffset;
int po = ooffset;
if ((ooffset < 0) || (toffset < 0) || (toffset > (long) thisSeq.length() - len)
        || (ooffset > (long) otherSeq.length() - len)) {
    return false;
while (len-- > 0) {
    char c1 = thisSeq.charAt(to++);
...
booleanregionMatches(byte[] ba1, int pos1, byte[] ba2, int pos2, int len)
Tests if two byte regions are equal.
int to = +pos1;
int po = pos2;
if ((pos2 < 0) || (pos1 < 0) || (pos1 > ((long) ba1.length - len)) || (pos2 > ((long) ba2.length - len))) {
    return false;
while (len-- > 0) {
    byte c1 = ba1[to++];
    byte c2 = ba2[po++];
...
booleanregionMatches(byte[] subValue, byte[] superValue, int offset)
Checks whether subValue matches the region in superValue starting at offset offset.
for (int i = 0; i < subValue.length; i++) {
    if (subValue[i] != superValue[i + offset]) {
        return false;
return true;
booleanregionMatches(char[] source, char[] target, int sIndex)
tIndex + sc.length <= tc.length .
if (source.length < sIndex + target.length)
    return false;
int i, len = target.length;
for (i = 0; i < len; i++) {
    if (source[sIndex + i] != target[i])
        return false;
return true;
...
booleanregionMatches(CharSequence a, int i, CharSequence b, int j, int len)
region Matches
if (i + len > a.length() || j + len > b.length() || i < 0 || j < 0 || len < 0) {
    return false;
while (len-- > 0) {
    if (a.charAt(i++) != b.charAt(j++)) {
        return false;
return true;
booleanregionMatches(CharSequence cs, boolean ignoreCase, int thisStart, CharSequence substring, int start, int length)
Green implementation of regionMatches.
if (cs instanceof String && substring instanceof String) {
    return ((String) cs).regionMatches(ignoreCase, thisStart, (String) substring, start, length);
} else {
    return cs.toString().regionMatches(ignoreCase, thisStart, substring.toString(), start, length);
booleanregionMatches(CharSequence cs, boolean ignoreCase, int thisStart, CharSequence substring, int start, int length)
region Matches
if (cs instanceof String && substring instanceof String) {
    return ((String) cs).regionMatches(ignoreCase, thisStart, (String) substring, start, length);
} else {
    return cs.toString().regionMatches(ignoreCase, thisStart, substring.toString(), start, length);
booleanregionMatches(CharSequence receiver, int thisOffset, String other, int otherOffset, int length, boolean ignoreCase)
region Matches
if (ignoreCase) {
    for (int i = 0; i < length; i++) {
        if (Character.toLowerCase(receiver.charAt(i + thisOffset)) != Character
                .toLowerCase(other.charAt(i + otherOffset)))
            return false;
} else {
    for (int i = 0; i < length; i++) {
...
booleanregionMatches(CharSequence seq, int toff, CharSequence other, int ooff, int len)
Implementation of String.regionMatches() for CharSequence.
if (toff < 0 || ooff < 0 || len < 0)
    return false;
boolean ret = true;
for (int i = 0; i < len; i++) {
    char c1;
    if (i + toff < seq.length())
        c1 = seq.charAt(i + toff);
    else {
...
booleanregionMatches(final char[] content, final int index, final String tag)
region Matches
final int length = tag.length();
for (int i = 0; i < length; i++) {
    if (content[i + index] != tag.charAt(i)) {
        return false;
return true;