I have a table with a mix of numbers and numbers that contain > or <. I would like to empty any cell that contains a number preceded by > or <.
Following previous KNIME discussion, I found the expression:
regexReplace($$CURRENTCOLUMN$$,"^[<>] \-?\d+(\.\d+)?", “”)
should help me to do that.
However, I have found that cells containing < number are indeed empty but cells containing > number are not affected.
your regex
^[<>] -?\d+(.\d+)?
currently means the following:
^ = beginning of string
[<>] = followwd by at least < or >
space = followed by a space
-? = followed by 0 or 1 minus-character
\d+ = followed by 1 or more number characters
(.\d+)? = followed by 0 or 1 times the combination dot-char and 1 or more numbers
so the probem in your current regex is that it expects the string to start with < or > and a space character
you could add ? before each condition to make it optional e.g.
^[<>]? ?-?\d+(.\d+)?
If you are having problems with regexs - consider to use a regex tester to look into the problem (even if you do not know regex - it helps to understand where the problem is)
a sorry just realized the problem was only about the > numbers.
I think you should test the exact cell content.
If the numbers have the exaxt format as the < numbers, the regex should work.
Maybe cop the cell contents in the tester to check which character does not Match