Support Questions
Find answers, ask questions, and share your expertise

Regex pattern to exclude table name containing keyword

Explorer

How to exclude certain table(names) in Nifi's CaptureChangeMySQL processor by passing a table name pattern?


For e.g. I have 500 tables and their corresponding history tables. Capture change should work for Employee, Order etc. but not for their corresponding tables EmployeeHistory, OrderHistory and so on. In short, tables with postfix 'History' should be filtered by the processor.


I tried the following values in the config/properties of the processor in the "Table Name Pattern" property, but no luck yet:

1) $.table_name:equals('DeviceHistory'):not()

2) ${table_name:equals('*History'):not()}

3) .(?!History)

4) (^(?!.History)$)

5) ^(?:(?!History).)*$

6) ^(?:(?!History).)$

7) ^(.?:(?!History))$

😎 ^*(.?:(?!History))$

@Matt Burgess

5 REPLIES 5

Have you tried negative lookbehind?

(?<!History)$ 

should match end of string if NOT preceded by "History".

Explorer

Thanks Hellmar. It is still capturing the tables post-fixed with the word History.Do you think of any other way I could pass a list of table names to "CaptureChangeMySQL processor" that it should capture? Currently, it captures any table and inserts into History tables(OrderHistory, ProductHistory) so it ends up inserting 2 records for every one insert in the main table(Order, Product etc).

Expert Contributor
.*(?<!History)$

Explorer

Thanks Gnovak. It is still capturing the tables post-fixed with the word History.Do you think of any other way I could pass a list of table names to "CaptureChangeMySQL processor" that it should capture? Currently, it captures any table and inserts into History tables(OrderHistory, ProductHistory) so it ends up inserting 2 records for every one insert in the main table(Order, Product etc). For e.g. a different processor that could read a file or a table and can somehow send the list of tables the next processor should consider?

Explorer

I saw NiFi doesn't let this processor accept any input so I tried 2 regex variations to accept a list of table names but in vain.:

(?:^|(?<= ))(Product|Order)(?:(?= )|$)

(?:[\s]|^)(Product|Order)(?=[\s]|$)

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.