Wildcard string matching

后端 未结 9 1466
醉话见心
醉话见心 2021-01-02 01:54

What is the most efficient wildcard string matching algorithm? I am asking only about an idea, it is not necessary to provide actual code.

I\'m thinking that such al

9条回答
  •  被撕碎了的回忆
    2021-01-02 02:44

    The performance will not just depend on the length of the string to search but also on the number (and type) of wildcards in the query string. If you are allowed to use a * which matches any number of characters, up to and including the entire document, and you can have any number of stars, this will put some limits on what is possible to get.

    If you can determine a match some string foo in O(f(n)) time, then the query foo_0*foo_1*foo_2*...*foo_m will take O(m*f(n)) time where m is the number of * wildcards.

提交回复
热议问题