Java Wildcard Match wildCardMatch(String text, String pattern)

Here you can find the source of wildCardMatch(String text, String pattern)

Description

wild Card Match

License

Open Source License

Declaration

public static boolean wildCardMatch(String text, String pattern) 

Method Source Code

//package com.java2s;

public class Main {
    public static boolean wildCardMatch(String text, String pattern) {
        // 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("\\*");
        for (int i = 0; i < cards.length; i++) {
            System.out.println(cards[i]);
        }/*ww  w .  j  a  v a2 s . co  m*/
        // 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());
        }
        return true;
    }
}

Related

  1. wildcardMatch(String pattern, String name)
  2. wildcardMatch(String pattern, String string)
  3. wildcardMatch(String string, String pattern)
  4. wildCardMatch(String text, String pattern)
  5. wildCardMatch(String text, String pattern)
  6. wildCardMatch(String text, String pattern)
  7. wildCardMatch(String text, String wildcard)
  8. wildcardMatches(String pattern, String text)