mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
53 lines
542 B
Markdown
53 lines
542 B
Markdown
# String Operators
|
|
|
|
## Join strings
|
|
Given a sample.yml file of:
|
|
```yaml
|
|
- cat
|
|
- meow
|
|
- 1
|
|
- null
|
|
- true
|
|
```
|
|
then
|
|
```bash
|
|
yq eval 'join("; ")' sample.yml
|
|
```
|
|
will output
|
|
```yaml
|
|
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
|
|
```
|
|
|