2022-02-14 02:22:51 +00:00
|
|
|
---
|
|
|
|
title: parse
|
|
|
|
layout: command
|
|
|
|
version: 0.59.0
|
|
|
|
---
|
|
|
|
|
2021-05-30 00:57:04 +00:00
|
|
|
Parse columns from string data using a simple pattern.
|
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
## Signature
|
|
|
|
|
|
|
|
```> parse (pattern) --regex```
|
2021-05-30 00:57:04 +00:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
- `pattern`: the pattern to match. Eg) "{foo}: {bar}"
|
|
|
|
- `--regex`: use full regex syntax for patterns
|
2021-05-30 00:57:04 +00:00
|
|
|
|
|
|
|
## Examples
|
2022-02-14 02:22:51 +00:00
|
|
|
|
|
|
|
Parse a string into two named columns
|
2021-05-30 00:57:04 +00:00
|
|
|
```shell
|
|
|
|
> echo "hi there" | parse "{foo} {bar}"
|
2022-02-14 02:22:51 +00:00
|
|
|
```
|
2021-05-30 00:57:04 +00:00
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
Parse a string using regex pattern
|
2021-05-30 00:57:04 +00:00
|
|
|
```shell
|
|
|
|
> echo "hi there" | parse -r "(?P<foo>\w+) (?P<bar>\w+)"
|
2022-02-14 02:22:51 +00:00
|
|
|
```
|