Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to match a pattern that contains * or ? #878

Closed
preethamrn opened this issue Jul 1, 2021 · 2 comments · Fixed by holtje/hive-config#92
Closed

No way to match a pattern that contains * or ? #878

preethamrn opened this issue Jul 1, 2021 · 2 comments · Fixed by holtje/hive-config#92
Labels
Milestone

Comments

@preethamrn
Copy link

Describe the bug
If a user wants to find all strings which exactly match a pattern, however the pattern contains a * or ?, it will match unwanted entries.

Version of yq: 4.9.3
Operating system: mac
Installed via: homebrew

Input Yaml
data1.yml:

- cat*
- cat*
- cat

Command
The command you ran:

yq eval '.[] | (. == "cat*")' data1.yml # results shown below
yq eval '.[] | (. == "cat\*")' data1.yml # escaping doesn't help
yq eval '.[] | (. == "cat.*")' data1.yml # regex isn't supported
yq eval '.[] | (. === "cat.*")' data1.yml # strict equality operator isn't supported

Actual behavior

true
true
true

Wanted behavior

true
true
false

Additional context
Either supporting regex matching or adding a === operator that does exact matching could fix this.

@mikefarah mikefarah added this to the 4.9.8 milestone Jul 7, 2021
@mikefarah
Copy link
Owner

Yeah good point - I think regex would work well

mikefarah added a commit that referenced this issue Jul 9, 2021
@mikefarah
Copy link
Owner

4.10.0 has new regex operators that can be used for this:

yq e '.[] | test("cat\*")' examples/data1.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants