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
  • Language Reference Guide
    • Readme
    • Types in the Nu Language
      • Basic Types
        • Any
        • Boolean
        • Integer
        • Float
        • Filesize
        • Duration
        • Datetime
        • Range
        • String
        • Record
        • List
        • Table
        • Closure
        • Nothing
        • Binary
        • Glob
        • Cell-Path
      • Other Data Types

        • Types that cannot be used to declare variables
          • Path
        • Types which are not declarable
          • Error
          • CustomValue
          • Block
      • Type signatures
      • Commands that interact with types
    • Operators
    • Flow control
      • if/else
      • loop
      • while
      • match
      • try/catch
      • break
      • return
      • continue
    • Filters
      • each and par-each
      • Filters to select subsets of data
      • where and filter
      • Understanding the difference between get and select
    • Custom Commands
    • Declarations
    • Variable Scope
    • Strings and Text Formatting
    • Helpers and debugging commands
    • Pipelines
    • MIME Types for Nushell

String

Description:A series of characters that represents text
Annotation:string
Literal Syntax:See Working with strings
Casts:into string
See also:Handling Strings
Types of Data - String

Language Notes:

  • Nu supports Unicode strings as the basic text type.

  • Internally strings are UTF-8 encoded, to ensure a consistent behavior of string operations across different platforms and simplify interoperability with most platforms and the web.

  • They have an associated length and do not rely on the C-style null character for termination.

  • As strings have to be valid UTF-8 for effective string operations, they can not be used to represent arbitrary binary data. For this please use the binary data type.

  • Different display operations might impose limitations on which non-printable or printable characters get shown. One relevant area are the ANSI escape sequences that can be used to affect the display on the terminal. Certain operations may choose to ignore those.

  • TBD: On which level string indexing should be performed: bytes or Unicode scalars.

Common commands that work with string

Many commands takes strings as inputs or parameters. These commands work with strings explicitly

  • str (subcommand)
    • For a complete list of subcommands, see: help str
  • into string
  • ansi strip
  • is-empty
  • is-not-empty

In addition to the above commands, most other into <type> commands take strings as inputs.

Common operators that work with string

  • + : Concatenate two strings
  • += : Mutates a string variable by concatenating its right side value.
  • == : ' True if 2 strings are equal
  • != : True if two strings are not equal
  • > : True if the left string is greater than the right string
  • >= : True if the left string is greater or equal than the right string
  • < : True if the left string is less than the right string
  • <= : True if the left string is less or equal than the right string
Edit this page on GitHub
Contributors: NotTheDr01ds, fdncred, maniaphobic
Prev
Range
Next
Record