How do I do string manipulations with the quotes characters?

I am using the standard String Manipulation node and want to remove quotes:

The output of a previous node results in a list of values that looks like this:
|[‘Asbs7.zb61-a-k-a1’, ‘Asbs7.zb61-a-j-a1’]|0.005233644859813084|0.411764705882353|29.769475357710657|
|—|—|—|—|
|[‘Asbs7.zb61-a-k-a1’, ‘Asbs7.zb61-a-j-a1’]|0.005233644859813084|0.3783783783783784|29.769475357710654|
|[‘’,** ‘Ssnj5302af’, ‘P0273-4’]|0.00411214953271028|0.6875|167.1875|**
|[‘’, ‘Ssnj5302af’, ‘P0273-4’]|0.00411214953271028|1.0|167.1875|

Note the [", construct

When I try to duplicate the character sequence, the fact that it is a double-quote throws off KNIME’s parsing of the rule and I cannot APPLY due to a syntax error:
replace($items$,“[”,“,”[" )

Is there another way to reference the errant quote to get rid of it?

Hi
certain characters require one or two backslashes () as escape signs to use them in string manipulation node
br

expanding on @Daniel_Weikert 's comment re backslashes, your statement would be written like this (assuming I understood correctly the replacement) :wink:

replace($items$,"[\",","[")
image

image

1 Like

Thanks for these ideas!

Using the backslash eliminated the syntax error, but it is not yet finding the relevant cases:

BEFORE
[‘’, ‘Asbs7.zb61-a-k-a1’, ‘Asbs7.zb61-a-j-a1’]

String Manipulation node SCRIPT
replace($items$,“[",”,“[” )

AFTER
[‘’, ‘Asbs7.zb61-a-k-a1’, ‘Asbs7.zb61-a-j-a1’]

I tried using 2 backslashes as suggested, but got a syntax error.

Hi @RVC2023 , it’s not easy to see what your exact strings are in the examples you’ve uploaded because the forum software interprets certain characters too.

Can you repost your BEFORE, AFTER, and SCRIPTS

but highlight each and press the preformatted text </> button in the forum window so it doesn’t lose anything:

otherwise, you mean to post something like this:
replace($items$,"[\",","[")

but it appears like this:

replace($items$,“[",”,“[”)

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.