Use the string manipulation node with the function substr(str,start,length), after having separated each cases and concatenate them all again ?KNIME_project5.knwf (26.1 KB)
I came up with a solution using couple of nodes. First use String manipulation node to remove “-ETS” part. Then split column based on “.” and afterwards combine first two columns using Column Combiner. At the end filter columns you need using Column Filter.
You can do this using a String Manipulation in which you enter this expression: regexReplace(regexReplace($input$, "-ETS", ""), "^[1-9a-zA-Z]*\\.(?=[1-9a-zA-Z]*\\.[1-9a-zA-Z]*)", "")
This is a nested regexReplace function which first removes the “-ETS” part and then the first part of the string if there are 3 parts left.
Sure,
[1-9a-zA-Z]* means any character in this range and can be repeated multiple times. So it matches your string in parts cause the dot character is not included.
The part that is in parentheses: (?=[1-9a-zA-Z]*\\.[1-9a-zA-Z]*)
checks whether such a string exists or not. So if some string like A2A.2A2 exists after the string which we specified before the parentheses then that string will be replaced. This is the case when you have 3 parts like “ATY.223.F10S” so the “ATY” will be replaced but if the string has 2 parts like “4RC.000” then the string will remain unchanged.
You are welcome but I have notice a mistake in my workflow cause when there are 3 parts left I was taking the first two instead of last two. Here is workflow to see how I have handled it if interested. 2019_01_11_String Manipulation.knwf (38.2 KB)
For these problems I think armingrudd solution using regex is a better approach cause it is only using one node.
Feel free to hit Solution button on replay that solves your problem