Module id.xfunction

Class WildcardMatcher

Object
WildcardMatcher

public class WildcardMatcher extends Object
Match text with a wildcards (called template) with any other text.

This matcher supports only one possible wildcard symbol which is '*'.

That way you don't need to worry to escape any symbols in your template like in case when using regexps.

For example given template "lol*lol":

  • lolasdlol - match
  • looooollol - does not match

Worst case complexity is O(n^m)

  • Constructor Details

    • WildcardMatcher

      public WildcardMatcher(String template)
    • WildcardMatcher

      public WildcardMatcher(List<String> templates)
  • Method Details

    • matches

      public boolean matches(String str)
      Check if given text matches all templates.
    • match

      public WildcardMatcher.Result match(String str)
      Match given text against all templates and return result