Short answer:
def has_match(row, regex):
return row['some_key']
.map(lambda x: x.match(regex))
.reduce(lambda x,y: x | y)
my_table.filter(lambda row: has_match(row, ".*tr.*"))
Longer answer:
match
is a method that you can call on a string. In general in ReQL when you have an array of X
and a function you want to apply to each element of the array you want to use the map
command. For example if you run:
r.expr(["foo", "boo", "bar"]).map(lambda x: x.match(".\*oo"))
you'll get back:
[True, True, False]
I'm a bit unclear from your question but I think what you want here is to get all the documents in which ANY of these strings matches regex. To see if any of them match you need to reduce the booleans together using or
so it would be:
list_of_bools.reduce(lambda x,y: x | y)