Continuing the discussion from Regex match help:
Now that we are able to identify (TRUE/FALSE) if a postcode is included in a string. Is there a way to extract the PostCode from the string into a separate column?
Continuing the discussion from Regex match help:
Now that we are able to identify (TRUE/FALSE) if a postcode is included in a string. Is there a way to extract the PostCode from the string into a separate column?
Hello,
In KNIME there are multiple ways to extract with Regex. I like to use the Column Expression node:
For example, matching a date for the Text column:
column(“Text”).match(/([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})/)[0]
If this seems like a little too much, I’ve attached a workflow where you simply double-click on the component (or right-click, then choose Configure) and you can enter the regex and column choice.
Regex.knar.knwf (16.9 KB)
Hi @B074534 , you can also use regex split (and a few friends!) to perform the extraction. I’ve dropped a demo workflow on the hub here
Hey there, just a small doubt. Will that regex expression work if there is a missing value in address ?
Hi @berserkersap, the regex is specifically looking for a part of the string that is in one of the recognised uk postcode formats so it isn’t dependent on anything else from the address to be present. If all you have is a postcode then it will see it.
If however the postcode itself has been incorrectly written, such as a zero in place of a letter O or the other way round, so that it is no longer in the right format, then the regex won’t find it.
Thanks @takbb for the clarification.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.