How to split with Regex

Hi everyone,

I am a new user of KNIME and I’m trying to learn this software. So I started to watch the online training courses which it were very helpful.

But I don’t find a lot of explanation about the Regular expression and how it can be used.

So, I have an issue about a text. I would like to use a Regex to split a string into 2 columns.

There is my exemple : IBM.mpc
MAC.klt

I would like to separate this string into 2 columns and the result will be IBM and mpc. I don’t need “.”.

Can you explain me how to do this, for example with using a Regex replacement ?

Indeed, I want to understand how it’s work with using group reference.

In additionnaly, I would like also, to learn more about Regex, so if you can tell me where I can find tutorial to help me to understand, I will apreciate it.

Thank you for you help and sorry if my english is bad. I hope you can understand what I have said.

2 Likes

Hi @Grayfox and welcome to the KNIME community.

You can use Regex Split node with this expression:
(.*)\.(.*)

You can also read more about the application of regex in KNIME here:
https://blog.statinfer.com/regex-in-knime-what-a-functionality-booster/

Best,
Armin

P.S.

7 Likes

Thank you so much, It’s work.

I also tried to do with a String Manipulation node, but I don’t understand how to use the RegexReplace fonction.

The String Manipulation has one output column and what regexReplace does is to replace a part of a string with some other string (or empty string).
This is how to use regexReplace:
regexReplace($column_name$, "regex pattern", "string")
Where “column_name” is the name of the column you want to modify. The “regex pattern” is the pattern to determine the part(s) of the original string which you want to modify. And the “string” is the new string which will replace the part(s) you have already determined.

Armin

Hi there!

Besides regex you may find handy to use Cell Splitter node for your task :wink:

Br,
Ivan

1 Like

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