Determines if an input string str matches a given search pattern. This does not do a direct sub-string check (like string.find), but instead checks if the input string fuzzily (or approximately) matches the pattern.

If the string matches, this returns a score of how well the input string matches the pattern. A string is considered to match the pattern if every letter pattern appears in order within the string.

For instance, the input "Cobblestone" is matched by the patterns "Cobblestone", "cbbl" and "cbst", in decreasing order of score. Similarly, the pattern "stn" matches "Stone", "Cobblestone" and "Stained Glass", again with decreasing scores.



  1. str string The string to match.
  2. pattern string The pattern to match against.


  1. number | nil The "score" for this match (higher is better), or nil if it did not match.