I have a list of dicts, something like:
[
{
"url": "bucket.amazonaws.com",
"file": "file1.txt"
},
{
"url": "github.com",
"file": "file2.txt"
}
]
I can filter the results to create a variable with files in AWS:
aws_files: "{{ array | selectattr('url', 'match', '.*amazonaws\.com.*') }}"
Or files in Github:
github_files: "{{ array | selectattr('url', 'match', '.*github\.com.*') }}"
How can I filter to find all files that don’t match either of the above patterns?
This is what I have but I don’t think it’s right:
remaining_files: "{{ not (array | selectattr('url', 'match', '.*(amazonaws|github)\.com.*')) }}"
This also doesn’t work:
remaining_files: "{{ array | selectattr('url', 'notmatch', '.*(amazonaws|github)\.com.*') }}"
Also, secondary question: is there a way to match the pattern anywhere in the string (so I don’t have to always add .*
to the beginning/end of the pattern).