Regex Split issue

Hi everyone,

I’m quite new here and i ’ starting learning how to use Knime.

I have currently an issue using Regex split.

Here details.
I have a cell containing the following string:

sderdes_2008_sddffgghhjklmoijy_@187181@

I would like to extract the @ID@

I have tested this simple : @(\d+)@ on https://www.freeformatter.com/regex-tester.html and it works

On KNime it return the following error
1074 input string(s) did not match the pattern or contained more groups than expected

Many thanks for your help
david

In the regex node you need to match the entire string with the regex. In your case, adding a .* at the beginning should help.

1 Like

The attached workflow shows how it would work. Split the string into three parts and the middle one is the one you want

I like the page (https://regex101.com) to test Regex Code.

The RegexSplit Node uses brackets () to indicate the groups to search for.
Depending on your strings you might have to modify the Regex for special cases like blanks etc.

kn_example_regex_split.knwf (10.7 KB)

Hi mlauber71,

Many thanks for your feedback.

I tried and it works, but i still have errors

(. @)(. )(@)
return 3 columns
1074 input string(s) did not match the pattern or contained more groups than expected

(.@)(.)(@)
return 3 columns
or .@(.)@ in order to get only 1 column with ID
24 input string(s) did not match the pattern or contained more groups than expected

David

That means you have strings that have variations in the Strings. You should try to modify the RegEx with some special strings. regex101 also explains what the various markers mean. This could play a role. You might try something like (white space | non white space)

Thanks,

i see what you mean.
I jave noticed some cells with no markers @ it might coming from this

david

Hi mlauber71

Many thanks again for your help.

I just have another question, because for few rows, the regex do not work properly.
I have tested in on regex101.com it works, but when i tried to test it on Knime, the Regex node i use
do do match anything.

here attachement
kn_example_regex_split (2).knwf (11.2 KB)