Compares two strings, but handles "regexp:" strings like HTML Selenese

@param expectedPattern
@param actual
@return true if actual matches the expectedPattern, or false otherwise
199493
public static boolean seleniumEquals( String expectedPattern, String actual )
    {
        if ( actual.startsWith( "regexp:" ) || actual.startsWith( "regex:" ) || actual.startsWith( "regexpi:" )
            || actual.startsWith( "regexi:" ) )
        {
            // swap 'em
            String tmp = actual;
            actual = expectedPattern;
            expectedPattern = tmp;
        }
        Boolean b;
        b = equalsHandleRegex( "regexp:", expectedPattern, actual, 0 );
        if ( b != null )
        {
            return b.booleanValue();
        }
        b = equalsHandleRegex( "regex:", expectedPattern, actual, 0 );
        if ( b != null )
        {
            return b.booleanValue();
        }
        b = equalsHandleRegex( "regexpi:", expectedPattern, actual, Pattern.CASE_INSENSITIVE );
        if ( b != null )
        {
            return b.booleanValue();
        }
        b = equalsHandleRegex( "regexi:", expectedPattern, actual, Pattern.CASE_INSENSITIVE );
        if ( b != null )
        {
            return b.booleanValue();
        }

        if ( expectedPattern.startsWith( "exact:" ) )
        {
            String expectedExact = expectedPattern.replaceFirst( "exact:", "" );
            if ( !expectedExact.equals( actual ) )
            {
                // System.out.println( "expected " + actual + " to not match " + expectedPattern );
                return false;
            }
            return true;
        }

        String expectedGlob = expectedPattern.replaceFirst( "glob:", "" );
        expectedGlob = expectedGlob.replaceAll( "([\\]\\[\\\\{\\}$\\(\\)\\|\\^\\+.])", "\\\\$1" );

        expectedGlob = expectedGlob.replaceAll( "\\*", ".*" );
        expectedGlob = expectedGlob.replaceAll( "\\?", "." );
        if ( !Pattern.compile( expectedGlob, Pattern.DOTALL ).matcher( actual ).matches() )
        {
            // System.out.println( "expected \"" + actual + "\" to not match glob \"" + expectedPattern
            // + "\" (had transformed the glob into regexp \"" + expectedGlob + "\"" );
            return false;
        }
        return true;
    }
1284697
public static void validateValues(Object actualValue, Object expectedValue, String pathExpression, TestContext context)
            throws ValidationException {
        try {
            if (actualValue != null) {
                Assert.isTrue(expectedValue != null,
                        ValidationUtils.buildValueMismatchErrorMessage(
                                "Values not equal for element '" + pathExpression + "'", null, actualValue));

                if (expectedValue instanceof Matcher) {
                    Assert.isTrue(((Matcher) expectedValue).matches(actualValue),
                            ValidationUtils.buildValueMismatchErrorMessage(
                                    "Values not matching for element '" + pathExpression + "'", expectedValue, actualValue));
                    return;
                }

                if (!(expectedValue instanceof String)) {
                    Object converted = TypeConversionUtils.convertIfNecessary(actualValue, expectedValue.getClass());

                    if (converted == null) {
                        throw new CitrusRuntimeException(String.format("Failed to convert value '%s' to required type '%s'", actualValue, expectedValue.getClass()));
                    }

                    if (converted instanceof List) {
                        Assert.isTrue(converted.toString().equals(expectedValue.toString()),
                                ValidationUtils.buildValueMismatchErrorMessage(
                                        "Values not equal for element '" + pathExpression + "'", expectedValue.toString(), converted.toString()));
                    } else if (converted instanceof String[]) {
                        String convertedDelimitedString = StringUtils.arrayToCommaDelimitedString((String[]) converted);
                        String expectedDelimitedString = StringUtils.arrayToCommaDelimitedString((String[]) expectedValue);

                        Assert.isTrue(convertedDelimitedString.equals(expectedDelimitedString),
                                ValidationUtils.buildValueMismatchErrorMessage(
                                        "Values not equal for element '" + pathExpression + "'", expectedDelimitedString, convertedDelimitedString));
                    } else if (converted instanceof byte[]) {
                        String convertedBase64 = Base64.encodeBase64String((byte[]) converted);
                        String expectedBase64 = Base64.encodeBase64String((byte[]) expectedValue);

                        Assert.isTrue(convertedBase64.equals(expectedBase64),
                                ValidationUtils.buildValueMismatchErrorMessage(
                                        "Values not equal for element '" + pathExpression + "'", expectedBase64, convertedBase64));
                    } else {
                        Assert.isTrue(converted.equals(expectedValue),
                                ValidationUtils.buildValueMismatchErrorMessage(
                                        "Values not equal for element '" + pathExpression + "'", expectedValue, converted));
                    }
                } else {
                    String expectedValueString = expectedValue.toString();
                    String actualValueString;
                    if (List.class.isAssignableFrom(actualValue.getClass())) {
                        actualValueString = StringUtils.arrayToCommaDelimitedString(((List)actualValue).toArray(new Object[((List)actualValue).size()]));
                        expectedValueString = expectedValueString.replaceAll("^\\[", "").replaceAll("\\]$", "").replaceAll(",\\s", ",");
                    } else {
                        actualValueString = actualValue.toString();
                    }

                    if (ValidationMatcherUtils.isValidationMatcherExpression(String.valueOf(expectedValueString))) {
                        ValidationMatcherUtils.resolveValidationMatcher(pathExpression,
                                actualValueString,
                                String.valueOf(expectedValueString),
                                context);
                    } else {
                        Assert.isTrue(actualValueString.equals(expectedValueString),
                                ValidationUtils.buildValueMismatchErrorMessage(
                                        "Values not equal for element '" + pathExpression + "'", expectedValueString, actualValueString));
                    }
                }
            } else if (expectedValue != null) {
                if (expectedValue instanceof Matcher) {
                    Assert.isTrue(((Matcher) expectedValue).matches(null),
                            ValidationUtils.buildValueMismatchErrorMessage(
                                    "Values not matching for element '" + pathExpression + "'", expectedValue, null));
                } else if (expectedValue instanceof String) {
                    String expectedValueString = expectedValue.toString();

                    if (ValidationMatcherUtils.isValidationMatcherExpression(expectedValueString)) {
                        ValidationMatcherUtils.resolveValidationMatcher(pathExpression,
                                null,
                                expectedValueString,
                                context);
                    } else {
                        Assert.isTrue(!StringUtils.hasText(expectedValueString),
                                ValidationUtils.buildValueMismatchErrorMessage(
                                        "Values not equal for element '" + pathExpression + "'", expectedValueString, null));
                    }
                } else {
                    throw new ValidationException("Validation failed: " + ValidationUtils.buildValueMismatchErrorMessage(
                            "Values not equal for element '" + pathExpression + "'", expectedValue, null));
                }
            }
        } catch (IllegalArgumentException | AssertionError e) {
            throw new ValidationException("Validation failed:", e);
        }
    }
429606
function assert(actual, expected, message) {
  if (toString.call(expected) === '[object RegExp]' && expected.test(actual)) {
    return;
  } else if (eql(actual, expected)) {
    return;
  }

  var pad = Array(5).join(' ');
  var msg = message + '\n\n'
    + pad + 'Actual:   ' + inspect(actual) + '\n'
    + pad + 'Expected: ' + inspect(expected) + '\n';

  return new AssertionError(msg, {
    actual: actual,
    expected: expected,
    showDiff: assert.showDiff
  });
}
1214640
@GwtIncompatible("java.util.regex.Pattern")
  public void matches(Pattern regex) {
    if (!regex.matcher(actual()).matches()) {
      failWithActual("expected to match", regex);
    }
  }
610875
public static function match($actual, $expected)
    {
        $a = static::actual($actual);
        $e = static::expected($expected);

        static::_buildDescription($a, $e);
        return $a === $e;
    }
861588
public static function assertStringMatchIgnoreWhitespace(
        $expected, $actual, $message='') {
          Assert::assertThat(
            $actual,
            new StringMatchIgnoreWhitespace($expected),
            $message);
    }
1098653
public static boolean isValidPattern(String pattern) {
    if (pattern == null) {
      return false;
    }
    String canon = pattern.replace('/', '.');
    return ClassName.isQualifiedName(canon)
        || ClassName.isStarQualifiedName(canon);
  }
1228846
function mimeMatch (expected, actual) {
  // invalid type
  if (expected === false) {
    return false
  }

  // split types
  var actualParts = actual.split('/')
  var expectedParts = expected.split('/')

  // invalid format
  if (actualParts.length !== 2 || expectedParts.length !== 2) {
    return false
  }

  // validate type
  if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) {
    return false
  }

  // validate suffix wildcard
  if (expectedParts[1].substr(0, 2) === '*+') {
    return expectedParts[1].length <= actualParts[1].length + 1 &&
      expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length)
  }

  // validate subtype
  if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) {
    return false
  }

  return true
}
756453
private boolean startsWithAFilteredPAttern(String string)
    {
        Iterator<String> iterator = filteredFrames.iterator();
        while (iterator.hasNext())
        {
            if (string.trim().startsWith(iterator.next()))
            {
                return true;
            }
        }
        return false;
    }
150583
protected void ensureValidFlags(final String actual, 
                                    final char[] expected) {
        if (actual == null) return;
        StringBuilder unexpected = null;
        for (int i = 0; i < actual.length(); i++) {
            char c = actual.charAt(i);
            if (Arrays.binarySearch(expected, c) < 0) {
                if (unexpected == null) unexpected = new StringBuilder();
                unexpected.append(c);
            }
        }
        if (unexpected != null) {
            throw FormatException.formatFlagsMismatch(
                    unexpected.toString(), getFormatName());
        }
    }
1156213
public static void assertEquals(String message, XmlCursor expected, XmlCursor actual)
  {
    for (int child = 0; true; child++)
    {
      boolean child1 = expected.toChild(child);
      boolean child2 = actual.toChild(child);
      if (child1 != child2)
      {
        fail(message, "Different XML structure near " + QNameHelper.pretty(expected.getName()));
      }
      else if (expected.getName() != null && !expected.getName().equals(actual.getName()))
      {
        fail(message, "Expected element: '" + expected.getName()
          + "' differs from actual element: '" + actual.getName() + "'");
      }
      else if (child == 0 && !child1)
      {
        if (!(expected.getTextValue().equals(actual.getTextValue())))
        {
          fail(message, "Expected value for element " + QNameHelper.pretty(expected.getName()) + " -> '"
            + expected.getTextValue() + "' differs from actual value '" + actual.getTextValue() + "'");
        }
        break;
      }
      else if (child1)
      {
        assertEquals(message, expected, actual);
        expected.toParent();
        actual.toParent();
      }
      else
      {
        break;
      }
    }

    assertAttributesEqual(message, expected, actual);
  }
1168107
private static boolean matchesPatternList(final String str, final List<Pattern> patterns) {
        if (patterns != null) {
            for (final Pattern pattern : patterns) {
                if (pattern.matcher(str).matches()) {
                    return true;
                }
            }
        }
        return false;
    }
778821
public static void assertEquals(String message, Object expected, Object actual) {
        if (expected == null && actual != null || expected != null && !expected.equals(actual)) {
            fail(message);
        }
    }
713006
private static void checkPattern(String s) throws ProblemException {
        // Package names like foo.bar.gamma are allowed, and
        // package names suffixed with .* like foo.bar.* are
        // also allowed.
        Pattern p = Pattern.compile("[a-zA-Z_]{1}[a-zA-Z0-9_]*(\\.[a-zA-Z_]{1}[a-zA-Z0-9_]*)*(\\.\\*)?+");
        Matcher m = p.matcher(s);
        if (!m.matches()) {
            throw new ProblemException("The string \""+s+"\" is not a proper package name pattern.");
        }
    }
962720
private boolean validatePattern(Object validationObject, Annotation annotate)
    {
        if (checkNullObject(validationObject))
        {
            return true;
        }

        java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(((Pattern) annotate).regexp(),
                ((Pattern) annotate).flags().length);
        Matcher matcherPattern = pattern.matcher((String) validationObject);
        if (!matcherPattern.matches())
        {
            throwValidationException(((Pattern) annotate).message());
           
        }

        return true;
    }
1203606
function assertExpectations({assertion, actual, expectations, message, prefix, stack}) {
	if (!isError(actual)) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			values: [formatWithLabel(`${prefix} exception that is not an error:`, actual)]
		});
	}

	const actualStack = actual.stack;

	if (hasOwnProperty(expectations, 'is') && actual !== expectations.is) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected to be strictly equal to:', expectations.is)
			]
		});
	}

	if (expectations.instanceOf && !(actual instanceof expectations.instanceOf)) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected instance of:', expectations.instanceOf)
			]
		});
	}

	if (typeof expectations.name === 'string' && actual.name !== expectations.name) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected name to equal:', expectations.name)
			]
		});
	}

	if (typeof expectations.message === 'string' && actual.message !== expectations.message) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected message to equal:', expectations.message)
			]
		});
	}

	if (expectations.message instanceof RegExp && !expectations.message.test(actual.message)) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected message to match:', expectations.message)
			]
		});
	}

	if (typeof expectations.code !== 'undefined' && actual.code !== expectations.code) {
		throw new AssertionError({
			assertion,
			message,
			stack,
			actualStack,
			values: [
				formatWithLabel(`${prefix} unexpected exception:`, actual),
				formatWithLabel('Expected code to equal:', expectations.code)
			]
		});
	}
}
641138
public boolean match(ParserTokenType expected) {
      ParserToken next = lookAhead(0);
      if (next == null || !next.type.isInstance(expected)) {
         return false;
      }
      consume();
      return true;
   }