REGEX match for numeric value OR null value

Hi all,

I’m very new to REGEX. I’m trying to filter out rows based on if a column (string) matches a numeric value or is null.

Based on some googling, I’ve tried:

^\d*.?\d*$|^null$
^\d*.?\d*$|^\w$

In both cases, the null values end up not being included in the match. Any suggestions on what I’m doing wrong?

Cheers,
David.

Hi @davidbaker

If you say if a value is null, do you mean a data null (a ? in KNIME) or the text “null”? Your Regex suggests the latter.

image

If you want to filter out a data null, I would go for a Rule-Based Row Filter in this case. It’s a bit easier to manage.

MISSING $column1$ OR $column1$ MATCHES "\b\d+\b" => TRUE

For string null it would be $column1$ = "null" OR $column1$ MATCHES "\b\d+\b" => TRUE

3 Likes

Thank you @ArjenEX, that worked like a charm! And you were correct, I did mean ? in Knime.

2 Likes

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