{"id":13541295,"url":"https://github.com/fdncred/nu_plugin_regex","last_synced_at":"2025-04-06T15:12:07.954Z","repository":{"id":106105118,"uuid":"577479590","full_name":"fdncred/nu_plugin_regex","owner":"fdncred","description":"Nushell plugin to search text with regular expressions.","archived":false,"fork":false,"pushed_at":"2025-03-29T19:06:44.000Z","size":183,"stargazers_count":45,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T20:20:04.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","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/fdncred.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":"2022-12-12T20:42:54.000Z","updated_at":"2025-03-29T19:06:31.000Z","dependencies_parsed_at":"2024-04-01T16:27:53.982Z","dependency_job_id":"8bc4a161-bd25-4848-b557-be5f2560aef0","html_url":"https://github.com/fdncred/nu_plugin_regex","commit_stats":{"total_commits":42,"total_committers":2,"mean_commits":21.0,"dds":"0.023809523809523836","last_synced_commit":"600c4c72cb5b1a142a0abc8e1692edbfe98148cc"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdncred%2Fnu_plugin_regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdncred%2Fnu_plugin_regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdncred%2Fnu_plugin_regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdncred%2Fnu_plugin_regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fdncred","download_url":"https://codeload.github.com/fdncred/nu_plugin_regex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247500468,"owners_count":20948880,"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-08-01T10:00:43.305Z","updated_at":"2025-04-06T15:12:07.936Z","avatar_url":"https://github.com/fdncred.png","language":"Rust","readme":"# nu_plugin_regex\n\nThis is a nushell plugin to parse regular expressions.\n\n# Examples\n\n## Example 1 - match digits one or more times\n```nushell\n'abc123abc' | regex '\\d+'\n```\n```console\n╭───┬───────────┬───────┬───────┬─────╮\n│ # │   input   │ match │ begin │ end │\n├───┼───────────┼───────┼───────┼─────┤\n│ 0 │ abc123abc │ 123   │     3 │   6 │\n╰───┴───────────┴───────┴───────┴─────╯\n```\n## Example 2 - match single character in a list\n```nushell\n'abc123abc' | regex '[a-c]'\n```\n```console\n╭───┬───────────┬───────┬───────┬─────╮\n│ # │   input   │ match │ begin │ end │\n├───┼───────────┼───────┼───────┼─────┤\n│ 0 │ abc123abc │ a     │     0 │   1 │\n│ 1 │ abc123abc │ b     │     1 │   2 │\n│ 2 │ abc123abc │ c     │     2 │   3 │\n│ 3 │ abc123abc │ a     │     6 │   7 │\n│ 4 │ abc123abc │ b     │     7 │   8 │\n│ 5 │ abc123abc │ c     │     8 │   9 │\n╰───┴───────────┴───────┴───────┴─────╯\n```\n## Example 3 - match any word character one or more times\n```nushell\n'abc123abc' | regex '\\w+'\n```\n```console\n╭───┬───────────┬───────────┬───────┬─────╮\n│ # │   input   │   match   │ begin │ end │\n├───┼───────────┼───────────┼───────┼─────┤\n│ 0 │ abc123abc │ abc123abc │     0 │   9 │\n╰───┴───────────┴───────────┴───────┴─────╯\n```\n## Example 4 - match the output of `ls` with a list of characters\n```nushell\nls | each {|e| $e.name | regex '[Cc]'} | flatten\n```\n```console\n╭────┬─────────────────────────────┬───────┬───────┬─────╮\n│  # │            input            │ match │ begin │ end │\n├────┼─────────────────────────────┼───────┼───────┼─────┤\n│  0 │ .cargo                      │ c     │     1 │   2 │\n│  1 │ .vscode                     │ c     │     3 │   4 │\n│  2 │ CODE_OF_CONDUCT.md          │ C     │     0 │   1 │\n│  3 │ CODE_OF_CONDUCT.md          │ C     │     8 │   9 │\n│  4 │ CODE_OF_CONDUCT.md          │ C     │    13 │  14 │\n│  5 │ CONTRIBUTING.md             │ C     │     0 │   1 │\n│  6 │ Cargo.lock                  │ C     │     0 │   1 │\n│  7 │ Cargo.lock                  │ c     │     8 │   9 │\n│  8 │ Cargo.toml                  │ C     │     0 │   1 │\n│  9 │ LICENSE                     │ C     │     2 │   3 │\n│ 10 │ VSWorkspaceSettings.json    │ c     │     9 │  10 │\n│ 11 │ build-all-maclin.sh         │ c     │    12 │  13 │\n│ 12 │ build-all-windows.cmd       │ c     │    18 │  19 │\n│ 13 │ crates                      │ c     │     0 │   1 │\n│ 14 │ docker                      │ c     │     2 │   3 │\n│ 15 │ docs                        │ c     │     2 │   3 │\n│ 16 │ rust-toolchain.toml         │ c     │     9 │  10 │\n│ 17 │ src                         │ c     │     2 │   3 │\n│ 18 │ unstable_cargo_features.txt │ c     │     9 │  10 │\n╰────┴─────────────────────────────┴───────┴───────┴─────╯\n```\n## Example 5 - match with 2 unnamed capture groups\n```nushell\n'abc123abc' | regex '(\\w{3})(\\d{3})'\n```\n```console\n╭───┬───────────┬──────────────┬────────┬───────┬─────╮\n│ # │   input   │ capture_name │ match  │ begin │ end │\n├───┼───────────┼──────────────┼────────┼───────┼─────┤\n│ 0 │ abc123abc │ capgrp0      │ abc123 │     0 │   6 │\n│ 1 │ abc123abc │ capgrp1      │ abc    │     0 │   3 │\n│ 2 │ abc123abc │ capgrp2      │ 123    │     3 │   6 │\n╰───┴───────────┴──────────────┴────────┴───────┴─────╯\n```\n## Example 6 - match with 2 named capture groups\n```nushell\n'abc123abc' | regex '(?\u003cword\u003e\\w{3})(?\u003cnum\u003e\\d{3})'\n```\n```console\n╭───┬───────────┬──────────────┬────────┬───────┬─────╮\n│ # │   input   │ capture_name │ match  │ begin │ end │\n├───┼───────────┼──────────────┼────────┼───────┼─────┤\n│ 0 │ abc123abc │ capgrp0      │ abc123 │     0 │   6 │\n│ 1 │ abc123abc │ word         │ abc    │     0 │   3 │\n│ 2 │ abc123abc │ num          │ 123    │     3 │   6 │\n╰───┴───────────┴──────────────┴────────┴───────┴─────╯\n```\n## Example 7 - match with 2 named capture groups and 1 unnamed capture group\n```nushell\n'abc123abc' | regex '(?\u003cword\u003e\\w{3})(?\u003cnum\u003e\\d{3})(\\w{3})'\n```\n```console\n╭───┬───────────┬──────────────┬───────────┬───────┬─────╮\n│ # │   input   │ capture_name │  match    │ begin │ end │\n├───┼───────────┼──────────────┼───────────┼───────┼─────┤\n│ 0 │ abc123abc │ capgrp0      │ abc123abc │   0   │  9  │\n│ 1 │ abc123abc │ word         │ abc       │   0   │  3  │\n│ 2 │ abc123abc │ num          │ 123       │   3   │  6  │\n│ 3 │ abc123abc │ capgrp3      │ abc       │   6   │  9  │\n╰───┴───────────┴──────────────┴───────────┴───────┴─────╯\n```\n## Example 8 - match non-digits, digits, non-digits with unnamed capture groups\n```nushell\n'abc123abc' | regex '(\\D+)(\\d+)(\\D+)'\n```\n```console\n╭───┬───────────┬──────────────┬───────────┬───────┬─────╮\n│ # │   input   │ capture_name │   match   │ begin │ end │\n├───┼───────────┼──────────────┼───────────┼───────┼─────┤\n│ 0 │ abc123abc │ capgrp0      │ abc123abc │     0 │   9 │\n│ 1 │ abc123abc │ capgrp1      │ abc       │     0 │   3 │\n│ 2 │ abc123abc │ capgrp2      │ 123       │     3 │   6 │\n│ 3 │ abc123abc │ capgrp3      │ abc       │     6 │   9 │\n╰───┴───────────┴──────────────┴───────────┴───────┴─────╯\n```\n# Notes\n\n- capture group 0 is always reported when groups are detected. not sure if this is right. this was mainly done for example 7\n- results should match https://regex101.com/\n\n## Character Classes\n\n| Class | Description |\n|-|-|\n| `.` | Any character |\n| `\\d` | Any digit |\n| `\\D` | Any non-digit |\n| `\\w` | Any alphanumeric (Latin letters, digits, underscore) |\n| `\\W` | Any non-alphanumeric (All but \\w) |\n| `\\s` | White space |\n| `\\S` | Non-white space |\n| `\\t` | Horizontal tab |\n| `\\r` | Carriage return |\n| `\\n` | Line feed |\n| `\\v` | Vertical tab |\n| `\\f` | Form feed |\n| `^` | The beginning of text (or start-of-line with  |multi-line mode)\n| `$` | The end of text (or end-of-line with multi-line mode) |\n| `\\A` | Only the beginning of text (even with multi-line mode  |enabled)\n| `\\z` | Only the end of text (even with multi-line mode  |enabled)\n| `\\b` | A Unicode word boundary (\\w on one side and \\W, \\A,  |or \\z on other)\n| `\\B` | Not a Unicode word boundary |\n| `\\pN` | One letter name for Unicode character class |\n| `\\PN` | Negated one-letter name Unicode character class |\n| `[xyz]` | Either x, y or z |\n| `[^xyz]` | Any character except x, y or z |\n| `[a-z]` | Any character in range a-z |\n| `[[:^alpha:]]` | Negated (\\[^A-Za-z\\]) |\n| `[[:alnum:]]` |  alphanumeric (\\[0-9A-Za-z\\]) |\n| `[[:alpha:]]` |  alphabetic (\\[A-Za-z\\]) |\n| `[[:ascii:]]` |  ASCII (\\[\\x00-\\x7F\\]) |\n| `[[:blank:]]` |  blank (\\[\\t \\]) |\n| `[[:cntrl:]]` |  control (\\[\\x00-\\x1F\\x7F\\]) |\n| `[[:digit:]]` |  digits (\\[0-9\\]) |\n| `[[:graph:]]` |  graphical (\\[!-~\\]) |\n| `[[:lower:]]` |  lower case (\\[a-z\\]) |\n| `[[:print:]]` |  printable (\\[ -~\\]) |\n| `[[:punct:]]` |  punctuation (\\[!-/:-@\\[-`{-~\\]) |\n| `[[:space:]]` |  whitespace (\\[\\t\\n\\v\\f\\r \\]) |\n| `[[:upper:]]` |  upper case (\\[A-Z\\]) |\n| `[[:word:]]` |  word characters (\\[0-9A-Za-z_\\]) |\n| `[[:xdigit:]]` |  hex digit (\\[0-9A-Fa-f\\]) |\n\n## Grouping and flags\n```\n(exp)          numbered capture group (indexed by opening parenthesis)\n(?P\u003cname\u003eexp)  named (also numbered) capture group (allowed chars: [_0-9a-zA-Z.\\[\\]])\n(?:exp)        non-capturing group\n(?flags)       set flags within current group\n(?flags:exp)   set flags for exp (non-capturing)\n```\nFlags are each a single character. For example, (?x) sets the flag x and (?-x) clears the flag x. Multiple flags can be set or cleared at the same time: (?xy) sets both the x and y flags and (?x-y) sets the x flag and clears the y flag.\n\nAll flags are by default disabled unless stated otherwise. They are:\n```\ni     case-insensitive: letters match both upper and lower case\nm     multi-line mode: ^ and $ match begin/end of line\ns     allow . to match \\n\nU     swap the meaning of x* and x*?\nu     Unicode support (enabled by default)\nx     ignore whitespace and allow line comments (starting with `#`)\n```\n\n## Escape Sequences\n```\n\\*          literal *, works for any punctuation character: \\.+*?()|[]{}^$\n\\a          bell (\\x07)\n\\f          form feed (\\x0C)\n\\t          horizontal tab\n\\n          new line\n\\r          carriage return\n\\v          vertical tab (\\x0B)\n\\123        octal character code (up to three digits) (when enabled)\n\\x7F        hex character code (exactly two digits)\n\\x{10FFFF}  any hex character code corresponding to a Unicode code point\n\\u007F      hex character code (exactly four digits)\n\\u{7F}      any hex character code corresponding to a Unicode code point\n\\U0000007F  hex character code (exactly eight digits)\n\\U{7F}      any hex character code corresponding to a Unicode code point\n\n\\h : hex digit ([0-9A-Fa-f])\n\\H : not hex digit ([^0-9A-Fa-f])\n\\e : escape control character (\\x1B)\n\\K : keep text matched so far out of the overall match\n\\G : anchor to where the previous match ended\n```\n\n## Backreferences\n```\n\\1 : match the exact string that the first capture group matched\n\\2 : backref to the second capture group, etc\n```\n\n## Named Capture Groups\n```\n(?\u003cname\u003eexp) : match exp, creating capture group named name\n\\k\u003cname\u003e : match the exact string that the capture group named name matched\n(?P\u003cname\u003eexp) : same as (?\u003cname\u003eexp) for compatibility with Python, etc.\n(?P=name) : same as \\k\u003cname\u003e for compatibility with Python, etc.\n\nLook-around assertions for matching without changing the current position:\n\n(?=exp) : look-ahead, succeeds if exp matches to the right of the current position\n(?!exp) : negative look-ahead, succeeds if exp doesn’t match to the right\n(?\u003c=exp) : look-behind, succeeds if exp matches to the left of the current position\n(?\u003c!exp) : negative look-behind, succeeds if exp doesn’t match to the left\n```\nMore syntax information can be found at the regex crate docs [here](https://docs.rs/regex/1.7.0/regex/#syntax) and at the fancy-regex crate docs [here](https://docs.rs/fancy-regex/0.10.0/fancy_regex/#syntax)\n","funding_links":[],"categories":["Plugins"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdncred%2Fnu_plugin_regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffdncred%2Fnu_plugin_regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdncred%2Fnu_plugin_regex/lists"}