Hi, I would need a code in column expressions which returns a double value from the column price in an appended column “price-new” if the column “status” contains the string “L_*” . Is there a solution? Thank you in advance…
…the Asterisks Sign is a Joker for a string. Maybe it works with a Java-Snippet…
Hi @dibu
if (regexMatcher(column(“column1”),“L_\*.+”)){
toDouble(column(“column2”))
}
Change the names of columns. You can use “Else” to manage missing value of new column
GL
Hi mehrdad_bgh, thank you. I tried that in column expression and got the following Error-Message (Expected an Operand…)
Errors in code. Please fix the expression.
Expected an operand but found error
if (regexMatcher(column(“combined_string”),“L_*.+”)){
^ at line 1 at column 44
Hi @dibu,
I think the expression provided by @mehrdad_bgh has two back slashes (\\
) originally, not a single one.
So the expression actually is:
if (regexMatcher(column("column1"),"L_\\*.+")){
toDouble(column("column2"))
}
@mehrdad_bgh, when you want to share some code, you need to provide it as a preformatted text. If it’s a single line code, select the line and click on the “</>” icon or add a single back quote at the beginning and the end of the line:
`your code`
If it’s multi-line, add a triple back quote line at the beginning and the end like this:
```
Your code here
Second line here
```
KNIME_Example.xlsx (17.7 KB)
…here is my Example, the result should be column G. Thank you in advance!
Hi @armingrudd
I didn’t know that. Thank you for your information. But actually my code had one backslash() and I used two backslashes for sharing the code.
So you have missing values in the status column. Use this expression instead:
if (isMissing(column("status"))) null
else if (regexMatcher(column("status"),"L_\\*.*")) toDouble(column("price"))
@mehrdad_bgh; @armingrudd; thank you both! All of your Solutions are working. The KNIME Community is simply great!
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.