code: public static boolean wildCardMatch(String text, String pattern, char multiCharacterWildCardChar, boolean caseInsensitive)
      {
          if (caseInsensitive)
          {
              text = text.toLowerCase();
              pattern = pattern.toLowerCase();
          }
  
          String wildCardString = "" + multiCharacterWildCardChar;
          if (!Character.isLetter(multiCharacterWildCardChar))
          {
              wildCardString = "\\" + wildCardString;
          }
          // Create the cards by splitting using a RegEx. If more speed
          // is desired, a simpler character based splitting can be done.
          String [] cards = pattern.split(wildCardString);
  
          // Don't allow anything before the pattern begin unless the pattern begins with '%' - "abcd" should not match "cdef", but should match "%cdef"
          if ( cards.length != 0 && (pattern.charAt(0) != multiCharacterWildCardChar && text.indexOf(cards[0]) != 0))
              return false;
  
          // Iterate over the cards.
          for (String card : cards)
          {
              int idx = text.indexOf(card);
  
              // Card not detected in the text.
              if(idx == -1)
              {
                  return false;
              }
  
              // Move ahead, towards the right of the text.
              text = text.substring(idx + card.length());
          }
  
          // Don't allow anything beyond the pattern end unless the pattern and with '%'
          return !(pattern.charAt(pattern.length() - 1) != multiCharacterWildCardChar && text.length() != 0);
  
      }
docs: Matches the given text with the given pattern.
  Based on http://www.adarshr.com/papers/wildcard, added checks for wildcard at the start and at the end
  @param text The text to match
  @param pattern The pattern
  @param multiCharacterWildCardChar The character to use as wildcard.
  @param caseInsensitive Match is case insensitive or not.
  @return True if the text matches the pattern. False otherwise.