I have a JSON document I am querying for some data. I need to loop through the IDs and find any IDs that contain a letter. Currently I have:
cat results.json | jq '.array|map(select( (.id|contains("a")) or (.id|contains("b")) ))' etc. etc.
How can I write a more efficient query/regex to do this in one contains()
function e.g. something like:
cat results.json | jq '.array|map(select( (.id|contains("a-z")) ))' etc. etc.
Thanks!
To check whether a string contains a letter of the alphabet, you could use
test("[A-Za-z]")
.Consider also character classes, e.g.
For safety, you’ll probably also want to select or check for strings, e.g. using the form: