{"id":16306172,"url":"https://github.com/gfx/ruby-regexp_trie","last_synced_at":"2025-09-07T21:33:02.890Z","repository":{"id":56891621,"uuid":"50117781","full_name":"gfx/ruby-regexp_trie","owner":"gfx","description":"Fast keyword matching with the Trie algorithm (a Ruby port of Perl's Regexp::Trie)","archived":false,"fork":false,"pushed_at":"2022-09-21T00:35:48.000Z","size":5279,"stargazers_count":28,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T23:39:31.636Z","etag":null,"topics":["regexp","regexp-trie","regular-expression","ruby-library"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/regexp_trie","language":"Ruby","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/gfx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-21T15:47:59.000Z","updated_at":"2022-09-20T00:58:03.000Z","dependencies_parsed_at":"2022-08-21T00:50:59.224Z","dependency_job_id":null,"html_url":"https://github.com/gfx/ruby-regexp_trie","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx%2Fruby-regexp_trie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx%2Fruby-regexp_trie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx%2Fruby-regexp_trie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx%2Fruby-regexp_trie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gfx","download_url":"https://codeload.github.com/gfx/ruby-regexp_trie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243817302,"owners_count":20352535,"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":["regexp","regexp-trie","regular-expression","ruby-library"],"created_at":"2024-10-10T21:09:50.442Z","updated_at":"2025-03-16T14:30:34.606Z","avatar_url":"https://github.com/gfx.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RegexpTrie [![CI](https://github.com/gfx/ruby-regexp_trie/actions/workflows/CI.yml/badge.svg)](https://github.com/gfx/ruby-regexp_trie/actions/workflows/CI.yml) [![Gem Version](https://badge.fury.io/rb/regexp_trie.svg)](https://badge.fury.io/rb/regexp_trie)\n\n## Synopsis\n\n```ruby\n#!/usr/bin/env ruby\nrequire 'regexp_trie'\n\n# like Regexp.union()\np RegexpTrie.union(%w(foobar fooxar foozap fooza)) # /foo(?:bar|xar|zap?)/\np RegexpTrie.union(%w(foobar fooxar foozap fooza), option: Regexp::IGNORECASE) # /foo(?:bar|xar|zap?)/i\n\n# or object-oriented interface\nrt = RegexpTrie.new\n%w(foobar fooxar foozap fooza).each do |word|\n  rt.add(word)\nend\np rt.to_regexp # /foo(?:bar|xar|zap?)/\n```\n\nSee also the original [Regexp::Trie in Perl](https://metacpan.org/pod/Regexp::Trie).\n\n## Description\n\n`RegexpTrie` takes an arbitrary number of regular expressions and assembles them into a single regular expression (or RE) that matches all that the individual REs match.\n\nIn other words, this library provides a limited but optimized version of `Regexp.union()`, even thouh there are some incompatibilities with it.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'regexp_trie'\n```\n\n## Incompatibilities with the built-in `Regexp.union()`\n\n* `RegexpTrie` handles only literals. i.e. `RegexpTrie.union(\"foo.*bar\")` produces `/foo\\.\\*bar/`, not `/foo.*bar/`\n* `RegexpTrie` cannot handle empty strings.\n* The order of words does not matter:\n  * `Regexp.union(\"foo\", \"foobar\").match(\"foobar\") # =\u003e #\u003cMatchData \"foo\"\u003e`\n  * `RegexpTrie.union(\"foo\", \"foobar\").match(\"foobar\") # =\u003e #\u003cMatchData \"foobar\"\u003e`\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/gfx/regexp_trie.\n\n## See Also\n\n* https://metacpan.org/pod/Regexp::Assemble\n* https://metacpan.org/pod/Regexp::Trie\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\nThe original code is @dankogai's [Regexp::Trie](https://metacpan.org/pod/Regexp::Trie).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgfx%2Fruby-regexp_trie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgfx%2Fruby-regexp_trie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgfx%2Fruby-regexp_trie/lists"}