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