To get the format in “StringTo” column from the “String” column, use this expression in a String Manipulation node: regexReplace($String$, ".*-", "")
If you want to use the Column Expressions node instead: regexReplace(column("String"), ".*-", "")
.*- selects all the string before the dash character and the dash itself and since there are multiple dash characters in the string, everything to the last one is selected. If you put a caret “^” at the beginning of the regex and the ? after * ( ^.*?-) then it only selects the first match which means everything before the first dash and the first dash itself will be selected.
Thanks for your addition information. Completely understood!
I have also found some article on web for learning regex expression but it seems different in different tools . I will read the link from you in advance.
I have created the following regex expression in Column Rename (Regex) node:
(^.*_)
Target Column name is like: ABCD_EFG_001_00
The purpose is to match the string before the first “_”, so I consider ABCD should be selected.
But it doesn’t work ( all characters in the string has been selected).
Does Column Rename (Regex) node have different expression?
First, I’m sorry about a mistake in my previous post which I just edited.
You have to match the whole column name then if you want to use the first part (ABCD) in the replacing name, you should put the regex corresponding to the string in parentheses: (^.*?)_.*
Now you can use $1 in replacement which stands for ABCD in this example.
P.S.
Regex is the same in all nodes except when you are using \ to escape special characters. If you are using it in a expression inside e.g. a String Manipulation, you have to use another \ to escape the \.
But if you are using it in configuration settings, you don’t need to do that. That’s all.