mirror of
https://github.com/nushell/nushell.git
synced 2025-06-08 19:17:16 +02:00
# Description Simple `parse` patterns let you quickly put together simple parsers, but sometimes you aren't actually interested in some of the output (such as variable whitespace). This PR lets you use `{_}` to discard part of the input. Example: ```nushell "hello world" | parse "{foo} {_}" # => ╭───┬───────╮ # => │ # │ foo │ # => ├───┼───────┤ # => │ 0 │ hello │ # => ╰───┴───────╯ ``` here's a simple parser for the `apropops` using the `_` placeholder to discard the variable whitespace, without needing to resort to a full regex pattern: ```nushell apropos linux | parse "{name} ({section}) {_}- {topic}" # => ╭───┬───────────────────────────────────────┬─────────┬─────────────────────────────────────────────────────────────────────╮ # => │ # │ name │ section │ topic │ # => ├───┼───────────────────────────────────────┼─────────┼─────────────────────────────────────────────────────────────────────┤ # => │ 0 │ PAM │ 8 │ Pluggable Authentication Modules for Linux │ # => │ 1 │ aarch64-linux-gnu-addr2line │ 1 │ convert addresses or symbol+offset into file names and line numbers │ # => │ 2 │ ... │ ... │ ... │ # => │ 3 │ xcb_selinux_set_window_create_context │ 3 │ (unknown subject) │ # => │ 4 │ xorriso-dd-target │ 1 │ Device evaluator and disk image copier for GNU/Linux │ # => ╰───┴───────────────────────────────────────┴─────────┴─────────────────────────────────────────────────────────────────────╯ ``` # User-Facing Changes * `parse` simple patterns can now discard input using `{_}` # Tests + Formatting N/A # After Submitting N/A