Extract specific numbers from string (CNPJ)

Hi All,

I would like to extract specific numbers at the format 00000000/0000-00 from a string.
I tryed regexreplace, but is showing some error: “Evaluation of expression failed for row “Row2”: No group 1”

Am I doing something wrong?

The regex expression that I used:
replace(regexReplace($Infos$,“\d{8}\/\d{4}\-\d{2}”, “$1”), $Infos$, “”)

Hello @lluckams and welcome to the KNIME community

CNPJ is starting to sound somehow familiar to me…

You can test the following:

regexReplace($Infos$, "^.*\\s+(\\d+.*?)\\s+.*$", "$1")

This is, capturing group: the first group of digits (after space/es) + anything until next (space/es) - non greedy.



Thanks a lot @gonhaddock ! It worked!

1 Like

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