Class WildcardMatching

java.lang.Object
io.github.connellite.match.WildcardMatching

public class WildcardMatching extends Object
Glob-style wildcard matching for character sequences.

'?' matches exactly one arbitrary character; '*' matches any sequence of characters (including empty). Matching is greedy in the dynamic-programming sense: the full text matches the full pattern if some assignment of * spans satisfies all literals and '?'.

Time and space complexity are O(m·n) for text length m and pattern length n.

  • Constructor Details

    • WildcardMatching

      public WildcardMatching()
  • Method Details

    • isMatch

      public static boolean isMatch(CharSequence text, CharSequence pattern)
      Returns whether text matches pattern.
      Parameters:
      text - text to match; not null
      pattern - pattern with '?' and '*' wildcards; not null
      Returns:
      true if the whole text matches the whole pattern