java.util.regex.Pattern
使用 Boyer\xe2\x80\x93Moore 字符串搜索算法
/* Attempts to match a slice in the input using the Boyer-Moore string\n * matching algorithm. The algorithm is based on the idea that the\n * pattern can be shifted farther ahead in the search text if it is\n * matched right to left.\n */\n\nprivate void compile() {\n ----------------------\n -----------------------\n\n if (matchRoot instanceof Slice) {\n root = BnM.optimize(matchRoot);\n if (root == matchRoot) {\n root = hasSupplementary ? new StartS(matchRoot) : new Start(matchRoot);\n }\n } else if (matchRoot instanceof Begin || matchRoot instanceof First) {\n root = matchRoot;\n } else {\n root = hasSupplementary ? new StartS(matchRoot) : new Start(matchRoot);\n }\n}\n
Run Code Online (Sandbox Code Playgroud)\n