132ikl eb9eb09ac5
Make parse simple patterns ignore fields with placeholder (_) (#15873)
# 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
2025-06-03 03:11:05 +03:00
..