mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
Added split string operator
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# String Operators
|
||||
|
||||
## Join strings
|
||||
Given a sample.yml file of:
|
||||
@@ -17,3 +18,35 @@ will output
|
||||
cat; meow; 1; ; true
|
||||
```
|
||||
|
||||
## Split strings
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
cat; meow; 1; ; true
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq eval 'split("; ")' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
- cat
|
||||
- meow
|
||||
- "1"
|
||||
- ""
|
||||
- "true"
|
||||
```
|
||||
|
||||
## Split strings one match
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
word
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq eval 'split("; ")' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
- word
|
||||
```
|
||||
|
||||
|
||||
1
pkg/yqlib/doc/headers/String Operators.md
Normal file
1
pkg/yqlib/doc/headers/String Operators.md
Normal file
@@ -0,0 +1 @@
|
||||
# String Operators
|
||||
Reference in New Issue
Block a user