this might have already been solved but I couldn’t find anything. My goal is to loop through all (30+) columns and replace any occurrence of one or more asterisks with two dashes.
I’m using the Column Expression node, replacing column by column which I think is too complicated as a solution.
What I’m looking for is to loop through all columns dynamically. Unfortunately, the column expression - when chosing “Replace Column” - forces me to select a specific column and not set it to, for example, a variable. If that’s possible, then I haven’t figured it out yet. Help is highly appreciated here.
Here’s the code I’m using in the Column Expression (Replace Column):
// Example for column "CPUSpec3"
if(column("CPUSpec3") == null)
{null}
else
{
regexReplace(column("CPUSpec3"), "\\*+", "*")
regexReplace(column("CPUSpec3"), "\\*+", "*"), "\\*", "--")
}
Currently my table looks something like this:
CPUSpec1
CPUSpec2
CPUSpec3
CPUSpec4
Intel Core i7-12700KF,
8C+4c/20T, 3.60-5.00GHz,
********************
Boxed
Intel Core i7-14700KF,
8C+12c/28T, 3.40-5.60GHz,
5.60GHz (Turbo Boost Max 3.0),
********************
Intel Core i7-10700K,
8C/16T, 3.80-5.10GHz,
********************
Boxed w/o cooler
Intel Core i5-10600KF,
6C/12T, 4.10-4.80GHz,
Intel 1200 (LGA1200)
********************
Maybe the Column Expression node is not what I am looking for here?
I did try it but failed. Now I tried again and unchecked “Fail if expression can not be evaluated”. Now it works. Thanks so much!
Apart from that: I now need two String Manipulation (Multi Column) nodes to have both regexReplace functions to work. Any trick to combine both in one?
I think Regex evaluations are impossible on missing values : one can suppress missing value before evaluation (Missing value node).
I don’t really understand why you need two regexReplace. $\*+^ will select values with only one or more *.
I think Regex evaluations are impossible on missing values
True, would make no sense to evaluate what’s not there.
I don’t really understand why you need two regexReplace. $*+^ will select values with only one or more *.
I’m replacing all occurences of asterisks to exactly one asterisk and then replace the single asterisk with the two dashes since I never know if the amount of asterisks always is the same.
I just tried your suggested RegEx. This adds an asterisk to the beginning of any row that’s not null?