str escape-regex for strings
Escapes special characters in the input string with '\'.
Signature
> str escape-regex {flags} ...rest
Parameters
-
...rest: For a data structure input, escape strings at the given cell paths.
Input/output types:
| input | output |
|---|---|
| string | string |
| list<string> | list<string> |
| table | table |
| record | record |
Examples
Escape dots in an IP address.
> '192.168.1.1' | str escape-regex 192\.168\.1\.1
Escape a list of strings containing special characters.
> ['(abc)', '1 + 1'] | str escape-regex ╭───┬─────────╮ │ 0 │ \(abc\) │ │ 1 │ 1 \+ 1 │ ╰───┴─────────╯
Escape characters in a specific column of a table.
> [[pattern]; ['find.me'] ['(group)']] | str escape-regex pattern ╭───┬───────────╮ │ # │ pattern │ ├───┼───────────┤ │ 0 │ find\.me │ │ 1 │ \(group\) │ ╰───┴───────────╯
Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/str_escape-regex.html