{"id":15343701,"url":"https://github.com/spacewander/lua-resty-boyer-moore","last_synced_at":"2025-11-08T15:30:26.981Z","repository":{"id":71091877,"uuid":"174636148","full_name":"spacewander/lua-resty-boyer-moore","owner":"spacewander","description":null,"archived":false,"fork":false,"pushed_at":"2020-05-13T09:37:00.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-28T03:42:12.072Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spacewander.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-09T01:56:13.000Z","updated_at":"2020-05-13T09:37:02.000Z","dependencies_parsed_at":"2023-03-11T09:53:43.057Z","dependency_job_id":null,"html_url":"https://github.com/spacewander/lua-resty-boyer-moore","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"12b42e73b849209cc9fbb0c2839660b5ad638ed6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacewander%2Flua-resty-boyer-moore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacewander%2Flua-resty-boyer-moore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacewander%2Flua-resty-boyer-moore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacewander%2Flua-resty-boyer-moore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spacewander","download_url":"https://codeload.github.com/spacewander/lua-resty-boyer-moore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239558914,"owners_count":19658927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T10:49:02.724Z","updated_at":"2025-11-08T15:30:26.936Z","avatar_url":"https://github.com/spacewander.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Name\n\nlua-resty-boyer-moore - An implementation of [Boyer–Moore string-search algorithm](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm) in LuaJIT\n\nBuild status: [![Travis](https://travis-ci.org/spacewander/lua-resty-boyer-moore.svg?branch=master)](https://travis-ci.org/spacewander/lua-resty-boyer-moore)\n\n## MUST READ\n\n* Because the preprocession of the good suffix rule is expensive, it is disabled\nby default. If your case benefits from it (for example, there are many repeated\nsub-patterns), you could enable it via `make CC=\"$(CC) -DBM_GOOD_SUFFIX_ENABLED\"`.\n* To benefit from the Boyer-Moore algorithm, both the pattern and the search\nstring need to be large enough. For instance, pattern in one hundred bytes and\nsearch string in thousands of bytes. If your pattern is monotonous,\nlike searching DNA sequence, the Boyer-Moore version could be over 50% faster\nthan `string.find`. But in the most situations, `string.find` is faster.\nYou need to benchmark it with your data.\n\n## Synopsis\n\n```lua\nlocal boyer_moore = require \"resty.boyer-moore\"\nlocal pat = \"0123\"\n\nlocal from, to = boyer_moore.bm_find(\"01450123\", pat)\nif not from then\n    ngx.say(to)\nelse\n    ngx.say(from)\n    ngx.say(to)\nend\n```\n\nFor more examples, read the `t/sanity.t`.\n\n## Installation\n\nRun `make`. Then copy the `librestyboyermoore.so` to one of your `lua_package_cpath`.\nYes, this library uses a trick to load the shared object from cpath instead of system shared library path.\nFinally, add the `$pwd/lib` to your `lua_package_path`.\n\n[Back to TOC](#table-of-contents)\n\n## Functions\n\n### bm_find\n`syntax: from, to|err = bm_find(s, pat[, init])`\n\nThis function should work as the same as the LuaJIT's `string.find` function.\nUnlike `string.find`, you don't need to pass `true` as the fourth argument.\n\nThere is another difference that this function returns `nil, \"not found\"` when\nwe could not find the `pat` in the given `s`, and `nil, \"no memory\"` when there is no enough memory to\npreprocess good suffix rule (if enabled). Note that good suffix rule is disabled by default,\nsee the [Must Read](#must-read) section for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspacewander%2Flua-resty-boyer-moore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspacewander%2Flua-resty-boyer-moore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspacewander%2Flua-resty-boyer-moore/lists"}