public boolean matches(String expected, String actual) {
		boolean result;
		
		// Be graceful with empty strings
		if (actual == null) {
			actual = "";
		}
		
		if (isBooleanCommand()) {
			result = "true".equals(actual);
			
		} else if (expected.startsWith(REGEXP)) {
			final String regex = trim(removeStartIgnoreCase(expected, REGEXP));
			result = Pattern.compile(regex, Pattern.DOTALL).matcher(actual).matches();
			
		} else if (expected.startsWith(REGEXPI)) {
			final String regex = trim(removeStartIgnoreCase(expected, REGEXPI));
			result = Pattern.compile(regex, Pattern.DOTALL | Pattern.CASE_INSENSITIVE).matcher(actual).matches();
			
		} else if (expected.startsWith(EXACT)){
			final String str = trim(removeStartIgnoreCase(expected, EXACT));
			result = str.equals(actual);
			
		} else {
			// "glob:"
			final String pattern;
			if (expected.startsWith(GLOB)) {
				pattern = trim(removeStartIgnoreCase(expected, GLOB));
			} else {
				pattern = expected;
			}
			result = globToRegExp(pattern).matcher(actual).matches();
		}
		if (isNegateCommand()) {
			result = !result;
		}
		return result;
	}
public boolean matches ( String expected , String actual ) { boolean result ; if ( actual == null ) { actual = "" ; } if ( isBooleanCommand ( ) ) { result = "true" . equals ( actual ) ; } else if ( expected . startsWith ( REGEXP ) ) { final String regex = trim ( removeStartIgnoreCase ( expected , REGEXP ) ) ; result = Pattern . compile ( regex , Pattern . DOTALL ) . matcher ( actual ) . matches ( ) ; } else if ( expected . startsWith ( REGEXPI ) ) { final String regex = trim ( removeStartIgnoreCase ( expected , REGEXPI ) ) ; result = Pattern . compile ( regex , Pattern . DOTALL | Pattern . CASE_INSENSITIVE ) . matcher ( actual ) . matches ( ) ; } else if ( expected . startsWith ( EXACT ) ) { final String str = trim ( removeStartIgnoreCase ( expected , EXACT ) ) ; result = str . equals ( actual ) ; } else { final String pattern ; if ( expected . startsWith ( GLOB ) ) { pattern = trim ( removeStartIgnoreCase ( expected , GLOB ) ) ; } else { pattern = expected ; } result = globToRegExp ( pattern ) . matcher ( actual ) . matches ( ) ; } if ( isNegateCommand ( ) ) { result = ! result ; } return result ; }
<p><i>(From the Selenium docs)</i></p>
<p>
Various Pattern syntaxes are available for matching string values:
</p>
<ul>
<li><strong>glob:</strong><em>pattern</em>: Match a string against a
"glob" (aka "wildmat") pattern. "Glob" is a kind of limited
regular-expression syntax typically used in command-line shells. In a
glob pattern, "*" represents any sequence of characters, and "?"
represents any single character. Glob patterns match against the entire
string.</li>
<li><strong>regexp:</strong><em>regexp</em>: Match a string using a
regular-expression. The full power of JavaScript regular-expressions is
available.</li>
<li><strong>regexpi:</strong><em>regexpi</em>: Match a string using a
case-insensitive regular-expression.</li>
<li><strong>exact:</strong><em>string</em>:

Match a string exactly, verbatim, without any of that fancy wildcard
stuff.</li>
</ul>
<p>
If no pattern prefix is specified, Selenium assumes that it's a "glob"
pattern.
</p>
<p>
For commands that return multiple values (such as verifySelectOptions),
the string being matched is a comma-separated list of the return values,
where both commas and backslashes in the values are backslash-escaped.
When providing a pattern, the optional matching syntax (i.e. glob,
regexp, etc.) is specified once, as usual, at the beginning of the
pattern.
</p>

@param expected expected result, optionally prefixed
@param actual Actual result coming from Selenium
@return is it a match?