Spoon
June 15, 2018, 8:30am
1
Hi! I’m trying to do something incredibly simple and I’m going nuts. I’m a complete programming newbie, and this is far too big for Excel.
Basically, I have a load of big CSV files, where the data looks as follows:
For any negative value, I want to move the “-” to the front of the string so that I can convert it to an integer.
I’m going nuts trying to do this with regex formulas: regexreplace($Net$,((?:\d+.)?\d+)-),-$1)
But having very little luck. Any help would be super appreciated!
MH
June 15, 2018, 8:45am
2
The following pattern works in KNIME
Pattern: ((?:\d+.)?\d+)(\-?)
Replace: $2$1
2 Likes
Spoon
June 15, 2018, 8:48am
3
MH:
$2$1
Thank you so much! This absolutely works for individual cases, now I’m just missing some syntax that I’m not getting right.
I’m trying to apply this to a full column, doing the following:
regexReplace($Net$, ((?:\d+.)?\d+)(-?) ,$2$1)
I think having the $ around the 2 is somehow confusing it as I’ve already referenced $Net$, and I’m getting the following error: “Invalid settings: No such column: 2 (at line 1)”.
Thanks again!
MH
June 15, 2018, 9:11am
4
Hi @Spoon ,
now i realize which Node you were using ;-). You need to use double backslashes as an escape sequence and quotation marks:
This worked for me. Hope it will work for you too
3 Likes
Spoon
June 15, 2018, 9:16am
5
You’re absolutely wonderful. Can’t thank you enough- wish I could send some wine your way
1 Like
MH
June 15, 2018, 9:19am
6
Me too. I also wish you could do that!
2 Likes
system
Closed
June 22, 2018, 9:19am
7
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.