Filter based on partial matching / regex

Hello,

I’m trying to filter a table if any record in a column includes: “CTO” or “Chief Technology Officer”. I don’t need it to be case sensitive. “A CTO at Coca-Cola” should match but not “A CTIO at Coca-Cola”

The following doesn’t seem to work:
\b(?:CTO|Chief\stechnology\sofficer)\b

Is there another recommended way than regex for this?

Thx!

Hello @bluena,

There is a joke that goes “If you have a problem and the solution is Regex, now you have two problems.” :joy:

Personally, I won’t go the regex route. I will simply convert the case of the column with the roles to lowercase, then use a rule-based role filter to isolate the rows which include “cto” or “chief technology officer”. You can also use uppercase, but the case in your strings and the configuration of the rule has to match.

Here is the rule I created in the rule-based row filter node:

$role lowercase$ LIKE “cto” OR $role lowercase$ LIKE “chief technology officer” => TRUE

You can discard the lower case column with the column filter node.

image

3 Likes

To add, if you want to check if a records contains cto and other terms, you need to use wildcards in the LIKE statement, otherwise it will only filter literal matches.

$column1$ LIKE "*cto*" OR $column1$ LIKE "*chief technology officer*" => TRUE

2 Likes

That’s right!

I have the asterisks, but for some reason, they get deleted once I post the solution. :woman_shrugging:t4:

1 Like

Use the formatted text option when posting pieces of code on the forum and it will show properly next time :wink:

image

3 Likes

Good to know. Thanks!

1 Like

Thank you both for the clear and quick answer! :slight_smile:

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.