Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

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:

inputoutput
stringstring
list<string>list<string>
tabletable
recordrecord

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\) │
╰───┴───────────╯