str starts-with

For strings.

Check if an input starts with a string.

Command Type

built-in

Signature

> str starts-with {flags} (string) ...rest

Flags

  • --ignore-case, -i: Search is case insensitive.

Parameters

  • string: The string to match.
  • ...rest: For a data structure input, check strings at the given cell paths, and replace with result.

Input/output types:

input output
string bool
list<string> list<bool>
table table
record record

Examples

Checks if input string starts with ‘my’.

> 'my_library.rb' | str starts-with 'my'
true

Checks if input string starts with ‘Car’.

> 'Cargo.toml' | str starts-with 'Car'
true

Checks if input string starts with ‘.toml’.

> 'Cargo.toml' | str starts-with '.toml'
false

Checks if input string starts with ‘cargo’, case-insensitive.

> 'Cargo.toml' | str starts-with --ignore-case 'cargo'
true

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.