{"id":14156605,"url":"https://github.com/asg017/sqlite-regex","last_synced_at":"2025-04-05T11:09:56.673Z","repository":{"id":65370206,"uuid":"561894605","full_name":"asg017/sqlite-regex","owner":"asg017","description":"A fast regular expression SQLite extension, written in Rust","archived":false,"fork":false,"pushed_at":"2024-04-22T07:46:31.000Z","size":154,"stargazers_count":171,"open_issues_count":16,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-18T06:05:01.801Z","etag":null,"topics":["sqlite","sqlite-extension"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asg017.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2022-11-04T18:31:01.000Z","updated_at":"2024-10-05T17:11:47.000Z","dependencies_parsed_at":"2024-08-17T08:17:44.757Z","dependency_job_id":null,"html_url":"https://github.com/asg017/sqlite-regex","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":"0.025000000000000022","last_synced_commit":"fa0e6d2609afa3de82392f865454cf57d47d0df7"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asg017","download_url":"https://codeload.github.com/asg017/sqlite-regex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247325693,"owners_count":20920714,"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":["sqlite","sqlite-extension"],"created_at":"2024-08-17T08:07:04.031Z","updated_at":"2025-04-05T11:09:56.636Z","avatar_url":"https://github.com/asg017.png","language":"Rust","readme":"# sqlite-regex\n\nA fast and performant SQLite extension for regular expressions. Based on [`sqlite-loadable-rs`](https://github.com/asg017/sqlite-loadable-rs), and the [regex crate](https://crates.io/crates/regex).\n\nSee [_Introducing sqlite-regex: The fastest Regular Expression Extension for SQLite_](https://observablehq.com/@asg017/introducing-sqlite-regex) (Jan 2023) for more details!\n\nIf your company or organization finds this library useful, consider [supporting my work](#supporting)!\n\n![](./benchmarks/dates.png)\n\n## Usage\n\n```sql\n.load ./regex0\nselect 'foo' regexp 'f';\n\n```\n\n**Find all occurrences of a pattern in a string**\n\n```sql\nselect regex_find(\n  '[0-9]{3}-[0-9]{3}-[0-9]{4}',\n  'phone: 111-222-3333'\n);\n-- '111-222-3333'\n\nselect rowid, *\nfrom regex_find_all(\n  '\\b\\w{13}\\b',\n  'Retroactively relinquishing remunerations is reprehensible.'\n);\n/*\n┌───────┬───────┬─────┬───────────────┐\n│ rowid │ start │ end │     match     │\n├───────┼───────┼─────┼───────────────┤\n│ 0     │ 0     │ 13  │ Retroactively │\n│ 1     │ 14    │ 27  │ relinquishing │\n│ 2     │ 28    │ 41  │ remunerations │\n│ 3     │ 45    │ 58  │ reprehensible │\n└───────┴───────┴─────┴───────────────┘\n*/\n```\n\n**Extract capture group values by index or name**\n\n```sql\nselect\n  regex_capture(captures, 0)        as entire_match,\n  regex_capture(captures, 'title')  as title,\n  regex_capture(captures, 'year')   as year\nfrom regex_captures(\n  regex(\"'(?P\u003ctitle\u003e[^']+)'\\s+\\((?P\u003cyear\u003e\\d{4})\\)\"),\n  \"'Citizen Kane' (1941), 'The Wizard of Oz' (1939), 'M' (1931).\"\n);\n/*\n┌───────────────────────────┬──────────────────┬──────┐\n│       entire_match        │      title       │ year │\n├───────────────────────────┼──────────────────┼──────┤\n│ 'Citizen Kane' (1941)     │ Citizen Kane     │ 1941 │\n│ 'The Wizard of Oz' (1939) │ The Wizard of Oz │ 1939 │\n│ 'M' (1931)                │ M                │ 1931 │\n└───────────────────────────┴──────────────────┴──────┘\n*/\n```\n\n**Use RegexSets to match a string on multiple patterns in linear time**\n\n```sql\nselect regexset_is_match(\n  regexset(\n    \"bar\",\n    \"foo\",\n    \"barfoo\"\n  ),\n  'foobar'\n)\n```\n\n**Split the string on the given pattern delimiter**\n\n```sql\nselect rowid, *\nfrom regex_split('[ \\t]+', 'a b     c d    e');\n/*\n┌───────┬──────┐\n│ rowid │ item │\n├───────┼──────┤\n│ 0     │ a    │\n│ 1     │ b    │\n│ 2     │ c    │\n│ 3     │ d    │\n│ 4     │ e    │\n└───────┴──────┘\n*/\n```\n\n**Replace occurrences of a pattern with another string**\n\n```sql\nselect regex_replace(\n  '(?P\u003clast\u003e[^,\\s]+),\\s+(?P\u003cfirst\u003e\\S+)',\n  'Springsteen, Bruce',\n  '$first $last'\n);\n-- 'Bruce Springsteen'\n\nselect regex_replace_all('a', 'abc abc', '');\n-- 'bc bc'\n```\n\n## Documentation\n\nSee [`docs.md`](./docs.md) for a full API reference.\n\n## Installing\n\n| Language       | Install                                                        |                                                                                                                                                                                               |\n| -------------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Python         | `pip install sqlite-regex`                                     | [![PyPI](https://img.shields.io/pypi/v/sqlite-regex.svg?color=blue\u0026logo=python\u0026logoColor=white)](https://pypi.org/project/sqlite-regex/)                                                      |\n| Datasette      | `datasette install datasette-sqlite-regex`                     | [![Datasette](https://img.shields.io/pypi/v/datasette-sqlite-regex.svg?color=B6B6D9\u0026label=Datasette+plugin\u0026logoColor=white\u0026logo=python)](https://datasette.io/plugins/datasette-sqlite-regex) |\n| Node.js        | `npm install sqlite-regex`                                     | [![npm](https://img.shields.io/npm/v/sqlite-regex.svg?color=green\u0026logo=nodedotjs\u0026logoColor=white)](https://www.npmjs.com/package/sqlite-regex)                                                |\n| Deno           | [`deno.land/x/sqlite_regex`](https://deno.land/x/sqlite_regex) | [![deno.land/x release](https://img.shields.io/github/v/release/asg017/sqlite-regex?color=fef8d2\u0026include_prereleases\u0026label=deno.land%2Fx\u0026logo=deno)](https://deno.land/x/sqlite_regex)        |\n| Ruby           | `gem install sqlite-regex`                                     | ![Gem](https://img.shields.io/gem/v/sqlite-regex?color=red\u0026logo=rubygems\u0026logoColor=white)                                                                                                     |\n| Github Release |                                                                | ![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/asg017/sqlite-regex?color=lightgrey\u0026include_prereleases\u0026label=Github+release\u0026logo=github)                       |\n| Rust           | `cargo add sqlite-regex`                                       | [![Crates.io](https://img.shields.io/crates/v/sqlite-regex?logo=rust)](https://crates.io/crates/sqlite-regex)                                                                                 |\n\n\u003c!--\n| Elixir         | [`hex.pm/packages/sqlite_regex`](https://hex.pm/packages/sqlite_regex) | [![Hex.pm](https://img.shields.io/hexpm/v/sqlite_regex?color=purple\u0026logo=elixir)](https://hex.pm/packages/sqlite_regex)                                                                       |\n| Go             | `go get -u github.com/asg017/sqlite-regex/bindings/go`               | [![Go Reference](https://pkg.go.dev/badge/github.com/asg017/sqlite-regex/bindings/go.svg)](https://pkg.go.dev/github.com/asg017/sqlite-regex/bindings/go)                                     |\n--\u003e\n\nThe [Releases page](https://github.com/asg017/sqlite-regex/releases) contains pre-built binaries for Linux x86_64, MacOS, and Windows.\n\n### As a loadable extension\n\nIf you want to use `sqlite-regex` as a [Runtime-loadable extension](https://www.sqlite.org/loadext.html), Download the `regex0.dylib` (for MacOS), `regex0.so` (Linux), or `regex0.dll` (Windows) file from a release and load it into your SQLite environment.\n\n\u003e **Note:**\n\u003e The `0` in the filename (`regex0.dylib`/ `regex0.so`/`regex0.dll`) denotes the major version of `sqlite-regex`. Currently `sqlite-regex` is pre v1, so expect breaking changes in future versions.\n\nFor example, if you are using the [SQLite CLI](https://www.sqlite.org/cli.html), you can load the library like so:\n\n```sql\n.load ./regex0\nselect regex_version();\n-- v0.1.0\n```\n\nOr in Python, using the builtin [sqlite3 module](https://docs.python.org/3/library/sqlite3.html):\n\n```python\nimport sqlite3\ncon = sqlite3.connect(\":memory:\")\ncon.enable_load_extension(True)\ncon.load_extension(\"./regex0\")\nprint(con.execute(\"select regex_version()\").fetchone())\n# ('v0.1.0',)\n```\n\nOr in Node.js using [better-sqlite3](https://github.com/WiseLibs/better-sqlite3):\n\n```javascript\nconst Database = require(\"better-sqlite3\");\nconst db = new Database(\":memory:\");\ndb.loadExtension(\"./regex0\");\nconsole.log(db.prepare(\"select regex_version()\").get());\n// { 'regex_version()': 'v0.1.0' }\n```\n\nOr with [Datasette](https://datasette.io/):\n\n```\ndatasette data.db --load-extension ./regex0\n```\n\n## Supporting\n\nI (Alex 👋🏼) spent a lot of time and energy on this project and [many other open source projects](https://github.com/asg017?tab=repositories\u0026q=\u0026type=\u0026language=\u0026sort=stargazers). If your company or organization uses this library (or you're feeling generous), then please [consider supporting my work](https://alexgarcia.regex/work.html), or share this project with a friend!\n\n## See also\n\n- [sqlite-xsv](https://github.com/asg017/sqlite-xsv), A SQLite extension for working with CSVs\n- [sqlite-loadable](https://github.com/asg017/sqlite-loadable-rs), A framework for writing SQLite extensions in Rust\n- [sqlite-http](https://github.com/asg017/sqlite-http), A SQLite extension for making HTTP requests\n","funding_links":[],"categories":["sqlite","People"],"sub_categories":["As Main Database"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasg017%2Fsqlite-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasg017%2Fsqlite-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasg017%2Fsqlite-regex/lists"}