Get Specific Data using REGEX in KNIME

Hello Team,

Hope someone can help me get these data using Regex coding as I am using Regex Split node.

Here are some samples data and its expected output:

Note - data to get is always in the first one may it be number only or characters.

Data: 32061300 OEM SYNTHETIC ATF 27101932 830 6651 L 4.961,0000 18,2680 90.627,55 0, 00 0, 00 0, 00

Need to get: 32061300

Data1: 0043370157 Graxa lubrificante sintetica - ISOFLEX TOPAS L 32, 09274422 34039900 510 6653 KG 25,0000 227,4284 5.685,71 5.685,71 682,29 639,64 12,00 11,25

Need to get: 0043370157

Data2: 3339627 BOT 402 GRANEL 27101932 130 6656 LT 9.871,0000 37,6639 371.780,36 0, 00 0, 00 0, 00

Need to get: 3339627

Data3: 0021350764 Oleo lubrificante sintetico - KLUBERSYNTH CH 2-100 N, 34031900 510 6653 L 80,0000 462,6471 37.011,77 40.620,42 4.874,45 3.608,65 12,00 9,75

Need to get: 0021350764

Data4: LAB/PP/1665TF TIRRENO GREENRUST 7247-GM 27101932 030 6653 L 1.000,0000 28,3000 28.300,00 0, 00 0, 00 0, 00

Need to get: LAB/PP/1665TF

Data5: A301.G25 AGBA SPRAY - oleo lubrificante - 400 ml 27101932 030 6653 PC 24,0000 107,8336 2.588,01 0, 00 0, 00 0, 00

Need to get: A301.G25

Appreciate if you could share your thoughts here on how to put it in regex coding. Thank you so much!

Hi,

if you always want to split by the first space, try ([^ ]*).* in the Regex Split.
Alternatively, the Cell Splitter – KNIME Community Hub node might be an option with space as delimiter and setting the array size to 2.

Does this solve your problem?

3 Likes

Hello @trafalgarlaw,

I would go with String Manipulation node and substr() function where you’ll say that length is equal to the first found spae character. Syntax is following:
substr($yourColumnName$, 0, indexOf($yourColumnName$, " "))

Br,
Ivan

3 Likes

Thank you, it works!! Appreciate sharing the code.

Thank you also for providing other way to get the data I am expecting. Will try to check this as well.

1 Like

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