src/org/ohmage/util/StringUtils.java
public static Set<String> decodeSearchString(final String string) {
		if(isEmptyOrWhitespaceOnly(string)) {
			return Collections.emptySet();
		}
		
		// Escape the wildcard.
		String escapedString = string.replace("%", "\\%");
		
		Set<String> result = new HashSet<String>();
		Matcher regexMatcher = PATTERN_SEARCH.matcher(escapedString);
		while (regexMatcher.find()) {
		    if (regexMatcher.group(1) != null) {
		        // Add double-quoted string without the quotes
		        result.add(regexMatcher.group(1));
		    } else if (regexMatcher.group(2) != null) {
		        // Add single-quoted string without the quotes
		        result.add(regexMatcher.group(2));
		    } else {
		        // Add unquoted word
		        result.add(regexMatcher.group());
		    }
		}
		
		return result;
	}
/**
	 * Takes a string where spaces divide the search terms and quotes can group
	 * terms to prevent them from being divided. The result is a set of tokens
	 * to use in search. For example, the string 'I say "hello, world" to
	 * everyone." will be divided into five tokens, "I", "say", "hello, world",
	 * "to", and "everyone.".
	 * 
	 * @param string The search string to be tokenized.
	 * 
	 * @return A set of tokens. If the string is null or only whitespace, it
	 * 		   will be an empty set.
	 */
Takes a string where spaces divide the search terms and quotes can group
terms to prevent them from being divided. The result is a set of tokens
to use in search.

@param string The search string to be tokenized.

@return A set of tokens. If the string is null or only whitespace, it
will be an empty set.
Takes a string where spaces divide the search terms and quotes can group terms to prevent them from being divided . The result is a set of tokens to use in search . @param string The search string to be tokenized . @return A set of tokens . If the string is null or only whitespace it will be an empty set .
public static Set<String> decodeSearchString(final String string) {
		if(isEmptyOrWhitespaceOnly(string)) {
			return Collections.emptySet();
		}
		String escapedString = string.replace("%", "\\%");
		Set<String> result = new HashSet<String>();
		Matcher regexMatcher = PATTERN_SEARCH.matcher(escapedString);
		while (regexMatcher.find()) {
		    if (regexMatcher.group(1) != null) {
		        result.add(regexMatcher.group(1));
		    } else if (regexMatcher.group(2) != null) {
		        result.add(regexMatcher.group(2));
		    } else {
		        result.add(regexMatcher.group());
		    }
		}
		return result;
	}
public static Set < String > decodeSearchString ( final String string ) { if ( isEmptyOrWhitespaceOnly ( string ) ) { return Collections . emptySet ( ) ; } String escapedString = string . replace ( "%" , "\\%" ) ; Set < String > result = new HashSet < String > ( ) ; Matcher regexMatcher = PATTERN_SEARCH . matcher ( escapedString ) ; while ( regexMatcher . find ( ) ) { if ( regexMatcher . group ( 1 ) != null ) { result . add ( regexMatcher . group ( 1 ) ) ; } else if ( regexMatcher . group ( 2 ) != null ) { result . add ( regexMatcher . group ( 2 ) ) ; } else { result . add ( regexMatcher . group ( ) ) ; } } return result ; }
Takes a string where spaces divide the search terms and quotes can group
 terms to prevent them from being divided.
Takes a string where spaces divide the search terms and quotes can group terms to prevent them from being divided .
// Escape the wildcard. // Add double-quoted string without the quotes // Add single-quoted string without the quotes // Add unquoted word