how to split a cell: Regex Split

Hi all,

i´m new with Knime an d i´m learnig and anjoying it a lot, but i have a little problem. My cells have data like this:

    La ultima parada (lo peor de todo) (1999)

    7 vidas (1997)

    Parte de tu vida (2014) (TV) (co-dir)

i want to split them into 3 new cells, title( Parte de tu vida ), year( 2014 ), other( (TV) (co-dir) ). Hor could i do it.

Thank you for all.

Jose

 

To me the java snippet node springs to mind. With the java string operations you can do basically anything.

The data that you quoted, is that all in one cell? Is it separated by a newline ?

 

Alternatively you could probably also do it with the String Manipulation node, but you would need 3 of them run in sequence, one for each new column.

This expression for the "Regex Split" will do it:

  ^(.+) \((\d{4,4})\)(?: (.*))?

 

I skip the detailed explanation of what is what in the expression as the node's description contains a similar example.

Thanks,
 Bernd

Great, it works. Thank you wiswedel

Hi,

I have a column which is TimeStamp and has values as follows:

01.06.2008

02.03.2006

How can I keep only the year?

Thank you

Resolved.

I took an String to Date/Time and then a Time to String

You can also use the date field extractor after the String to date node.

Happy KNIMEing!

Iris

I am trying to use the RegEx Split node to extract values from a string contained within [] and ()

The expression I am using is 

\[([0-9]+)\].\(([0-9]+)\)

A sample string is 

SAMPLE & BRAND TEXT3 {IT} [84855115] (7702018089345)

All I get is ? in the two split columns even though the expression works as expected @ https://regex101.com/

Give this a shot using the Regex Split node:

^(.+) [(\d+)] ((\d+))(?: (.*))?

The first “(\d+)” extracts the numbers in the square brackets into column name= split_1 while the second “(\d+)” extracts the numbers in the parentheses into column name= split_2.

Output attached:

1 Like

2 posts were split to a new topic: Split string with Regex