{"id":17918043,"url":"https://github.com/bogdanp/cursive_re","last_synced_at":"2025-05-16T09:05:24.179Z","repository":{"id":43921661,"uuid":"154095380","full_name":"Bogdanp/cursive_re","owner":"Bogdanp","description":"Readable regular expressions for Python 3.6 and up.","archived":false,"fork":false,"pushed_at":"2024-10-23T07:17:48.000Z","size":25,"stargazers_count":360,"open_issues_count":0,"forks_count":11,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-16T09:05:18.030Z","etag":null,"topics":["python","python3","regex"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bogdanp.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":"2018-10-22T06:16:34.000Z","updated_at":"2025-04-03T15:29:31.000Z","dependencies_parsed_at":"2024-12-08T22:04:04.232Z","dependency_job_id":null,"html_url":"https://github.com/Bogdanp/cursive_re","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bogdanp%2Fcursive_re","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bogdanp%2Fcursive_re/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bogdanp%2Fcursive_re/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bogdanp%2Fcursive_re/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bogdanp","download_url":"https://codeload.github.com/Bogdanp/cursive_re/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254501557,"owners_count":22081528,"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":["python","python3","regex"],"created_at":"2024-10-28T20:09:33.453Z","updated_at":"2025-05-16T09:05:19.164Z","avatar_url":"https://github.com/Bogdanp.png","language":"Python","readme":"# cursive_re\n\nReadable regular expressions for Python 3.6 and up.\n\n## Installation\n\n    pip install cursive_re\n\n## Examples\n\n``` python\n\u003e\u003e\u003e from cursive_re import *\n\n\u003e\u003e\u003e hash = text('#')\n\u003e\u003e\u003e hexdigit = any_of(in_range('0', '9') + in_range('a', 'f') + in_range('A', 'F'))\n\u003e\u003e\u003e hexcolor = (\n...     beginning_of_line() + hash +\n...     group(repeated(hexdigit, exactly=6) | repeated(hexdigit, exactly=3)) +\n...     end_of_line()\n... )\n\u003e\u003e\u003e str(hexcolor)\n'^\\\\#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$'\n\n\u003e\u003e\u003e hexcolor_re = compile(hexcolor)\nre.compile('^\\\\#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$')\n\n\u003e\u003e\u003e hexcolor_re.match('#fff')\n\u003cre.Match object; span=(0, 4), match='#fff'\u003e\n\n\u003e\u003e\u003e hexcolor_re.match('#ffff') is None\nTrue\n\n\u003e\u003e\u003e hexcolor_re.match('#ffffff')\n\u003cre.Match object; span=(0, 7), match='#ffffff'\u003e\n\n\u003e\u003e\u003e domain_name = one_or_more(any_of(in_range('a', 'z') + in_range('0', '9') + text('-')))\n\u003e\u003e\u003e domain = domain_name + zero_or_more(text('.') + domain_name)\n\u003e\u003e\u003e path_segment = zero_or_more(none_of('/'))\n\u003e\u003e\u003e path = zero_or_more(text('/') + path_segment)\n\u003e\u003e\u003e url = (\n...     group(one_or_more(any_of(in_range('a', 'z'))), name='scheme') + text('://') +\n...     group(domain, name='domain') +\n...     group(path, name='path')\n... )\n\u003e\u003e\u003e str(url)\n'(?P\u003cscheme\u003e[a-z]+)://(?P\u003cdomain\u003e[a-z0-9\\-]+(?:\\.[a-z0-9\\-]+)*)(?P\u003cpath\u003e(?:/[^/]*)*)'\n```\n\n## Reference\n\n### `cursive_re.compile`\n\nCompile a cursive_re expression to a real regular expression.\n\n\n### `cursive_re.beginning_of_line`\n\nMatches the beginning of a line.\n\nExamples:\n\n    \u003e\u003e\u003e str(beginning_of_line())\n    '^'\n\n\n### `cursive_re.end_of_line`\n\nMatches the end of a line.\n\nExamples:\n\n    \u003e\u003e\u003e str(end_of_line())\n    '$'\n\n\n### `cursive_re.anything`\n\nMatches any character.\n\nExamples:\n\n    \u003e\u003e\u003e str(anything())\n    '.'\n\n\n### `cursive_re.literal`\n\nInserts a literal regular expression.\n\nExamples:\n\n    \u003e\u003e\u003e str(literal(r\"\\A\\w\"))\n    '\\\\A\\\\w'\n\n\n### `cursive_re.text`\n\nMatches the given string exactly, escaping any special characters.\n\nExamples:\n\n    \u003e\u003e\u003e str(text(\"abc\"))\n    'abc'\n\n\n### `cursive_re.any_of`\n\nMatches any of the given characters.\n\nExamples:\n\n    \u003e\u003e\u003e str(any_of(\"ab\"))\n    '[ab]'\n\n    \u003e\u003e\u003e str(any_of(text(\"ab\")))\n    '[ab]'\n\n    \u003e\u003e\u003e str(any_of(text(\"[]\")))\n    '[\\\\[\\\\]]'\n\n\n### `cursive_re.none_of`\n\nMatches none of the given characters.\n\nExamples:\n\n    \u003e\u003e\u003e str(none_of(\"ab\"))\n    '[^ab]'\n\n    \u003e\u003e\u003e str(none_of(text(\"ab\")))\n    '[^ab]'\n\n    \u003e\u003e\u003e str(none_of(text(\"[]\")))\n    '[^\\\\[\\\\]]'\n\n\n### `cursive_re.in_range`\n\nMatches a character in the given range.\n\nExamples:\n\n    \u003e\u003e\u003e str(in_range(\"a\", \"z\"))\n    'a-z'\n\n\n### `cursive_re.zero_or_more`\n\nMatches zero or more of the given expr.\n\nExamples:\n\n    \u003e\u003e\u003e str(zero_or_more(\"a\"))\n    '(?:a)*'\n\n    \u003e\u003e\u003e str(zero_or_more(text(\"a\")))\n    '(?:a)*'\n\n    \u003e\u003e\u003e str(zero_or_more(text(\"abc\")))\n    '(?:abc)*'\n\n    \u003e\u003e\u003e str(zero_or_more(group(text(\"abc\"))))\n    '(abc)*'\n\n\n### `cursive_re.one_or_more`\n\nMatches one or more of the given expr.\n\nExamples:\n\n    \u003e\u003e\u003e str(one_or_more(\"a\"))\n    '(?:a)+'\n\n    \u003e\u003e\u003e str(one_or_more(text(\"a\")))\n    '(?:a)+'\n\n    \u003e\u003e\u003e str(one_or_more(group(text(\"abc\"))))\n    '(abc)+'\n\n\n### `cursive_re.maybe`\n\nMatches an expr if present.\n\nExamples:\n\n    \u003e\u003e\u003e str(maybe(\"abc\"))\n    '(?:abc)?'\n\n    \u003e\u003e\u003e str(maybe(text(\"abc\")))\n    '(?:abc)?'\n\n    \u003e\u003e\u003e str(maybe(group(text(\"abc\"))))\n    '(abc)?'\n\n    \u003e\u003e\u003e str(maybe(any_of(\"abc\")))\n    '[abc]?'\n\n\n### `cursive_re.repeated`\n\nMatches an expr repeated an exact number of times.\n\nExamples:\n\n    \u003e\u003e\u003e str(repeated(\"a\", exactly=5))\n    '(?:a){5}'\n\n    \u003e\u003e\u003e str(repeated(text(\"a\"), exactly=5))\n    '(?:a){5}'\n\n    \u003e\u003e\u003e str(repeated(text(\"a\"), at_least=1))\n    '(?:a){1,}'\n\n    \u003e\u003e\u003e str(repeated(text(\"a\"), at_most=5))\n    '(?:a){0,5}'\n\n    \u003e\u003e\u003e str(repeated(text(\"a\"), at_least=2, at_most=5, greedy=False))\n    '(?:a){2,5}?'\n\n\n### `cursive_re.group`\n\nDenotes a group whose contents can be retrieved after a match\nis performed.\n\nExamples:\n\n    \u003e\u003e\u003e str(group(text(\"a\")))\n    '(a)'\n\n    \u003e\u003e\u003e str(group(any_of(\"abc\"), name=\"chars\"))\n    '(?P\u003cchars\u003e[abc])'\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbogdanp%2Fcursive_re","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbogdanp%2Fcursive_re","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbogdanp%2Fcursive_re/lists"}