{"id":23093108,"url":"https://github.com/crispengari/re-python","last_synced_at":"2026-05-15T22:05:59.515Z","repository":{"id":141094895,"uuid":"361129464","full_name":"CrispenGari/RE-python","owner":"CrispenGari","description":"💎 Regular expression in python.","archived":false,"fork":false,"pushed_at":"2021-07-05T14:10:26.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T17:02:42.689Z","etag":null,"topics":["nlp","nlp-python","pyth","python","python3","re","regexp","regular-expression","text-classification","text-clustering","text-processing"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/CrispenGari.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":"2021-04-24T10:11:28.000Z","updated_at":"2021-07-05T14:10:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"53e34bf9-919e-4404-82b2-b91d1b39773f","html_url":"https://github.com/CrispenGari/RE-python","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/CrispenGari%2FRE-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrispenGari%2FRE-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrispenGari%2FRE-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrispenGari%2FRE-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CrispenGari","download_url":"https://codeload.github.com/CrispenGari/RE-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247061233,"owners_count":20877166,"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":["nlp","nlp-python","pyth","python","python3","re","regexp","regular-expression","text-classification","text-clustering","text-processing"],"created_at":"2024-12-16T21:46:29.351Z","updated_at":"2025-10-25T21:38:57.578Z","avatar_url":"https://github.com/CrispenGari.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Regexp Python\n\nRegular expression in python.\n\n\u003e Regular expression are a powerful feature for text processing, they match patterns in a sentence.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://img.shields.io/static/v1?label=language\u0026message=python\u0026color=green\"/\u003e\n\u003cimg src=\"https://img.shields.io/static/v1?label=package\u0026message=re\u0026color=purple\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/CrispenGari/RE-python/blob/main/cover.png\" alt=\"cover\"/\u003e\n\u003c/p\u003e\n\n### 1. Special characters\n\n\u003e The following are special characters in regular expressions.\n\n```\n^       - matches the beginning of the sentence\n$       - matches the end of the sentence\n.       - matches all characters except new line\n\\       - escape special characters\nA|B     - matches expression A or B\n+       - matches at least one character\n*       - matches 0 or more characters\n?       - optional, matches 1 or 0 characters\n{m}     - matches the expression to it's left exactly m times\n{m,n}   - matches the expression to the left m to n times but not less\n{m, n}? - matches the expression to it's left m times and n ignores\n```\n\n### 2. Character classes (Special Sequence)\n\n\u003e The following are special sequences in regular expressions\n\n```\n\\w      - matches alphanumeric characters which is A-Z,a-z,0-9 and _ .\n\\d      - matches digits 0-9\n\\s      - matches white space characters \\t, \\n, \\r.\n\\S      - matches none white space characters\n\\b      - matches the boundary at the start or end of the word that is  \\w and \\W.\n\\B      - matches where \\b does not that is not word boundaries.\n\\A      - matches the expression to it's right at the absolute start of string wether in single or multiple line.\n\\Z      - Matches the expression to it's left at the absolute end of a string wether in single or multiple line.\n\n```\n\n### 3. Sets\n\n\u003e The following are sets in regular expression\n\n```\n[]      - contains a set of characters to match\n[akb]   - matches a, k or b\n[a-z]   - matches any character between a and z inclusively\n[a\\-z]  - matches a, -, or z\n[a-]    - matches a or -\n[-a]    - matches a\n[a-z0-9]- matches characters from a to z and also numbers from 0-9\n[(+*)]  - special characters becomes literal and this matches (,+, * and ).\n[^ab5]  - adding ^ in the character set bracket at the beginning will exclude all the characters in the character set, so thi will match all characters except a, b or 5\n```\n\n### 4. Groups\n\n\u003e The following are groups in regular expression.\n\n```\n()      - Matches the expression inside the parenthesis and groups it.\n(?)     - ? inside the parenthesis acts like extension notation. Its meaning depends on the character immediately to its right.\n(?PAB)  -  Matches the expression AB, and it can be accessed with the group name.\n(?aiLmsux) - Here, a, i, L, m, s, u, and x are flags:\n\n\na       — Matches ASCII only\ni       - Ignore case\nL       - Locale dependent\nm       - Multi-line\ns       - Matches all\nu       - Unicode characters\nx       - Verbose\n\n(?:A)   - matches the expression represented by A, but unlike (?PAB), it cannot be retrieved afterwards.\n\n(?#...) - A comment. Contents are for us to read, not for matching.\n\nA(?=B)  - Lookahead assertion. This matches the expression A only if it is followed by B\n\nA(?!B)  - Negative lookahead assertion. This matches the expression A only if it is not followed by B.\n\n(?\u003c=B)A - Positive lookbehind assertion. This matches the expression A only if B is immediately to its left. This can only matched fixed length expressions.\n\n(?\u003c!B)A - Negative lookbehind assertion. This matches the expression A only if B is not immediately to its left. This can only matched fixed length expressions.\n\n(?P=name) - Matches the expression matched by an earlier group named 'name'\n\n(...)\\1   - The number 1 corresponds to the first group to be matched. If we want to match more instances of the same expression, simply use its number instead of writing out the whole expression again. We can use from 1 up to 99 such groups and their corresponding numbers.\n```\n\n### 5. Popular `re` Functions:\n\n\u003e The following are the popular regular expression function in python.\n\n#### 5.1 `re.findall(A, B)`\n\n\u003e Matches all instances of an expression A in a string B and returns them in a list\n\n#### 5.2 `re.search(A, B)`\n\n\u003e Matches the first instance of an expression A in a string B, and returns it as a re match object.\n\n#### 5.3 `re.split(A, B)`\n\n\u003e Split a string B into a list using the delimiter A\n\n#### 5.4 `re.sub(A, B, C)`\n\n\u003e Replace A with B in the string C.\n\n#### 5.5 `re.match(A, B)`\n\n\u003e Returns the first occurrence of A in B\n\n#### 5.7 `re.compile(A, B)`\n\n\u003e Flags should be used first in the expression string.\n\n#### 5.8 re.finditer(pattern, string, flags=0)\n\n\u003e Return an iterator yielding MatchObject instances over all non-overlapping matches for the RE pattern in string.\n\n### Code Examples\n\nThe code examples are found in the `re.ipynb` file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrispengari%2Fre-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrispengari%2Fre-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrispengari%2Fre-python/lists"}