Simple wildcard search in dataframes

Hello All,

This seems like such a trivial thing, but I couldn’t get it to work.

I’m simply trying to filter a dataframe column by a wildcard search. What is the right syntax?

df = DataFrame(:a => ["abcdef","abcdeg","xyzefg"], :b => [1,2,3])

so I’m looking for something like abc*g on column :a

I tried this, but this doesn’t seem to work.

contains.(df.a, r"abc*g")

Thanks.

I think you just have a regex error

julia> contains.(df.a, r"abc.*g")
3-element BitVector:
 0
 1
 0

I always have a tab of Regex101 open when working with regex.

2 Likes

OK, thanks, I knew it was something stupid I did.

Regex is my weakness…