Rule based row filter: How to escape asterisk in regex?

EDIT:
to show the regex’ correctly.

Hi,
1st post in this forum.

I am trying to filter rows which contain a string starting with an asterisk:

column ‘name’
row 1: ‘*test_with_asterisk’
row 2: ‘test_without_asterisk’

Using rule based row filter, with expression
$name$ MATCHES /^\*/ => TRUE

Doesn’t work.

regex /\*/ doesn’t work either.

Am I doing something completely wrong or is it maybe a bug?

Thx, Rolf

My fault, no bug.

Right regex:

/^[\*]+.*/

Thx!

2 Likes

Hello @rollo67,

and welcome to KNIME Community!

In some nodes you’ll need multiple backslashes in order to escape special characters. See here for more. In your example to match asteriks this is expression:
$name$ MATCHES /\\*.*/ => TRUE

Besides standard nodes, for dealing with regex you might find Regex Extractor useful:

Br,
Ivan

6 Likes

Hi @rollo67

Welcome to the forum! :slight_smile:
Just wanted to propose *.* in the normal Row Filter node, but happy you found a solution!

3 Likes

Hi Ivan,

Thx for your quick reply, the double backslash made the trick!

And thx as well for the hint to the regex extractor.

Wonderful forum.

Rolf

2 Likes

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