Regex Split won't accept pattern

Hi there all,

I’m strugging with a regex pattern, which works normally. However, If I enter it in the Regex Split-Node in order to split a column into multiple new columns based on a regex, it just won’t accept it and print an warning like “1 input string(s) did not match the pattern or contained more groups than expected”.

My string is for example “A BCDEFGH IJKLM” and I want to add a pipe “|” after "A " and “BC”, based on the pattern “\w{1,2}”. My initial idea was to splitt the column, add the pipe and then join the strings together again.

Does anyone have an idea or a tip, how to solve this obstacle? Thank you in advance.

Hi there @nooby,

welcome to KNIME Community Forum!

It would help if you explain logic behind adding pipe into your string. Are you adding pipe after “A” and “BC” or adding pipe after first and third char or something else?

Br,
Ivan

Hi @ipazin,

thank you for the reply.

There are two possible ways for the values:

  • Single letter and a whitespace -> "A "
  • Two letter - “BC”

In order to count them later on, I want to mark each value (single and double) with a pipe.

Regards,
nooby

Hi @nooby,

if I got you right you want to count every occurrence of string "A " and “BC” in your string? Then you can avoid adding pipe and use count() function in String Manipulation node maybe?

Br,
Ivan

Hi @ipazin,

sorry, If it wasn’t clear. I just want to set a pipe after each combination. The counting is not my focus on this point.

Wanted result -> A |BC|DE|FG|H |IJ|KL|M |

Cheers,
nooby

Hi @nooby,

does that satisfy your needs?

47

Kind regards
Mike

1 Like

Ah @mw,

I love you. Thank you a lot! @ipazin, thank you as well for trying to help me.

Regards,
nooby

2 Likes

Hi there @nooby,

glad I could help although not providing solution :slight_smile:

Br,
Ivan

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