From fa40740e7740992174357d277a517d94a66490aa Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Sun, 10 Sep 2023 22:24:38 +0200 Subject: [PATCH] add case-insensitive example to `where` (#10299) related to - https://discord.com/channels/601130461678272522/614593951969574961/1150395064292495400 # Description two cool things about the `where` command - it's versatile enough to allow creating a case-insensitive version of itself - it does not require the explicit use of a closure this PR adds an example showing how to filter with `where` but case-insensitively and without an explicite closure. # User-Facing Changes new example to `where`: ```nushell Find case-insensitively files called "readme", without an explicit closure > ls | where ($it.name | str downcase) =~ readme ``` # Tests + Formatting the new example test above. # After Submitting --- crates/nu-command/src/filters/where_.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/nu-command/src/filters/where_.rs b/crates/nu-command/src/filters/where_.rs index 5665049775..3907d46244 100644 --- a/crates/nu-command/src/filters/where_.rs +++ b/crates/nu-command/src/filters/where_.rs @@ -152,6 +152,18 @@ not supported."# example: "ls | where type == file | sort-by name -n | enumerate | where {|e| $e.item.name !~ $'^($e.index + 1)' } | each {|| get item }", result: None, }, + Example { + description: r#"Find case-insensitively files called "readme", without an explicit closure"#, + example: "ls | where ($it.name | str downcase) =~ readme", + result: None, + }, + Example { + description: "same as above but with regex only", + example: "ls | where name =~ '(?i)readme'", + result: None, + } + + ] } }