I have a table whose rows I want to filter (by choosing or excluding them) on the basis of a series of criteria contained in a table. The criteria table has column fields corresponding by position to those of the data table. Each row of the table must be compared with all the criteria and if at least one is satisfied it is selected, otherwise it is discarded. The comparison is a simple pattern matching of the data row content with the criteria row pattern. To meet a criterion, the data row values must match one by one with the patterns in the criteria row. Although I havenâ€™t done many tests to verify, I believe I have found a solution. But I would like to see other more succinct and / or more performing and / or more idiomatic or simply different solutions.

I would also like if someone also made observations on parts of the script that can be done differently to improve something (anything).

```
criteria=DataFrame(Col1=["a1", "a2", ".*", ".*", "a4"],
Col2=[".*", "hfg", ".*end\$", ".*", "^start.*"],
Col3=[".*", ".*", "all3", ".*btw.*", ".*"])
df=DataFrame(col1=["a1", "a2", "a1", "a2", "a3", "a4", "a2", "a5"],
col2=["bbbEnd","hfg", "start1","3eND","start3","cccEND","start5","alend"],
col3=["tutto", "all3","btw3", "abtw4", "all2", "all3", "all4", "all2"])
```

```
function matchdot(ptrn, str)
mtch=true
for i in 1:length(str)
mtch=mtch && (occursin(str[1],ptrn[i])||occursin(Regex(ptrn[i],"i"),str[i]))
end
return mtch
end
function matchSomeCriteria(crt, row)
match=false
for r in eachrow(crt)
match=match||matchdot(r,row)
end
return match
end
filter(v -> !matchSomeCriteria(criteria,v),df)
filter(v -> matchSomeCriteria(criteria,v),df)
```