Skip to content

Add String Slice #2385

@d7sd6u

Description

@d7sd6u

Please describe your feature request.
It would be really nice if yq supported string slicing. #44 this issue requested exactly that and was closed as completed even though that is clearly false, there is no page in docs related to string slicing and it does not work with strings in the latest yq version.

Describe the solution you'd like
If we have data1.yml like:

country: Australia

And we run a command:

yq '.country[4:]'

it could output

ralia

Describe alternatives you've considered
Using https://github.com/kislyuk/yq
Using jq and json <-> yaml converter
Using .field | split("") | .[3:] | join("")

Additional context
Slicing is one of the basic functions in any language, in jq and in unix utilities. But yq does not support it for string and support for arrays is mediocre: #2280 yq is the only CLI utility out there that supports frontmatter manipulation and has jq-like capabilities, so it is very sad that it is under maintained and underdeveloped in terms of standard library and query parsing

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions