{"id":19458531,"url":"https://github.com/postgrespro/dict_regex","last_synced_at":"2026-06-07T21:32:10.009Z","repository":{"id":149600970,"uuid":"64128351","full_name":"postgrespro/dict_regex","owner":"postgrespro","description":null,"archived":false,"fork":false,"pushed_at":"2016-07-25T12:15:45.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-22T17:12:34.417Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/postgrespro.png","metadata":{"files":{"readme":"README.dict_regex","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2016-07-25T11:18:27.000Z","updated_at":"2023-03-08T14:34:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"b621b215-a183-424a-a509-739239bc0195","html_url":"https://github.com/postgrespro/dict_regex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fdict_regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fdict_regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fdict_regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fdict_regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postgrespro","download_url":"https://codeload.github.com/postgrespro/dict_regex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240662852,"owners_count":19837369,"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-11-10T17:27:27.835Z","updated_at":"2025-02-25T11:42:40.309Z","avatar_url":"https://github.com/postgrespro.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Regular expressions dictionary for PostgreSQL\n=============================================\n\nThis code is a dictionary for PostgreSQL full-text search, which combines the\ngeneric synonym and thesaurus ones with the power of regular expressions.\n\n* Configuration\n\nThe dictionary accepts one obligatory parameter - RULES, which has to be set to\nthe file describing parsing rules and output recipes.\n\nIts syntax is very simple.  Each non-empty line is either a comment\n(when started with '#' symbol), or a conversion rule, and in the latter case\nhas to contain whitespace-separated pattern and output recipe.\n\nCurrently, pattern has to match the _integer_ (one, two or more) number of input\ntokens; they will be replaced with a single one. All whitespaces between input\nwords are treated as single one.\n\nIf the output recipe is empty, the match is considered to be a stop-word, and\nis not processed by the dictionaries next in line.\n\nThe pattern is explicitly enclosed by the dictionary inside \"^...$\" construct, so\nyou need not include these.\n\nIf several rules are matching the input stream, the longest one will be\naccepted, and if there are several - the one which is earlier in the rules.\n\nThe pattern syntax is basically the one of PCRE, and is compatible to Perl. The\none exception is the following (related to the PCRE working in partial matching\nmode): repeated single characters such as \"a{2,4}\" and repeated single\nmetasequences such as \"\\d+\" are not permitted if the maximum number of\noccurrences is greater than one. Optional items such as \"\\d?\" (where the maximum\nis one) are permitted. Quantifiers with any values are permitted after\nparentheses, so the invalid examples above can be coded as \"(a){2,4}\" and \"(\\d)+\",\ncorrespondingly.\n\nAlso, as for now, only 9 matched substrings are supported (**$1** - **$9**). They will\nbe translated to lower case along with all the output recipe.  If output recipe\ncontains several words, it will be returned as a set of tokens with the same\nposition, i.e. they will be treated as the synonyms.\n\n* Usage\n \n 1. Compile and install it. The compilation requires PCRE (http://pcre.org)\n    headers and library in compiler-accessible paths; in a case, tweak the\n    Makefile according to your settings\n\n 2. Load the dictionary definitions into your database\n    \n    psql qq \u003c dict_regex.sql\n\n 3. Create the conversion rules, and point the dictionary to the file\n\n    qq# ALTER TEXT SEARCH DICTIONARY regex (RULES = '@your_rules_file@');\n    ALTER TEXT SEARCH DICTIONARY\n\n 4. Use it as you wish\n\n* Examples\n\nSome basic example rules:\n\n# Synonym expansion - 'catalogue' will be indexed both as is and as 'catalog'\n# on the query side, it means 'catalogue' -\u003e 'catalogue' \u0026 'catalog'\ncatalogue catalogue catalog\n\n# Thesaurus - index 'regular expression' as single token\nregular\\sexpressions? regex\n\n# Complex behaviour - transpose parts of a 8-digit number, 12345678 -\u003e 56781234\n(\\d\\d\\d\\d)(\\d\\d\\d\\d) $2$1\n\n* Todo\n\n - Improve handling of config file - allow whitespaces in patterns and in recipes\n - Improve recipe parsing - allow more than 9 matches per pattern\n - Improve performance of pattern matching - do not reparse already processed\n   parts of incoming string\n - Think about integration with other dictionaries (like thesaurus does) for\n   normalization before pattern matching\n - Implement complex expansion of 'synonyms' - i.e. rule options to control\n   complex AND and OR behaviour of returned lexemes.\n - Replace (or optionally replace) PCRE with PostgreSQL built-in regular\n   expressions engine\n\n* Security notice\n\nBe warned that dict_regex is insecure - id does not perform any special checks\non the location and content of the rule file. So, it may be pointed to any file\nreadable by postmaster, and it is possible to user to reconstruct the file\ncontents. Do not use it in security-critical environments, or modify the source\naccordingly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostgrespro%2Fdict_regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostgrespro%2Fdict_regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostgrespro%2Fdict_regex/lists"}