However, I want to be able to replace more than one protein name using the same node. For example:
regexReplace($Submitted entities found$,“NUP107;”,“X0X033;”) and
regexReplace($Submitted entities found$,“ATF2;”,“XOXO44;”)
But when I put both lines together the node gives me an error message.
Is there an expression or regex symbol that I can use between this two lines to tell the node to execute both lines of command?
I guess this new question is related to the previous one for which I provided a possible solution. If I understood well and based on this previous solution, I have implemented a solution here below attached.
It is based on a recursive loop because I believe you are obliged to iterate several times on the same string to gradually replace each different found Protein Name. If for instance, you have a sentence where you have 3 different Protein Names, you would need to gradually iterate 3 times in total until all the Protein Names are replaced.
The first part of the previous solution was essentially this one below:
As you can see, I have added a mock Dictionary of Protein Name Pairs, on the left the Protein Names in your sentences, on the right the new names to use as replacement.
it was not really so much related to the last question. I was using your first solution successfully after some modifications.
My question was more fundamental. I wanted to know if there is a way that the String manipulation node can actually read two lines of code that modify two different protein names at the same time. See the example attached in the figures
I’m not right now in front of my computer but answering from the smartphone.
To answer quickly, you can only have one line of code in the -string manipulator- node.
The only way to do a “double” regex replacement would be to imbricate the two regex functions in this way : regexReplace( regexReplace( ×, y, z), y’, z’)
My pleasure. By the way, my suggested solution here, regardless of the first part, is taking a dictionary of pairs of words and replacing them in your sentences. It is hence a generic solution of what you want to do with several regex replacements. In my dictionary, every pair of words corresponds to one of your regReplaces. You would just hence need to create your own dictionary based on your regex needs.
You can still be a programmer when using KNIME. You can either use Java snippet nodes, if you are a Java programmer, or other integration nodes, like Python or R.
In fact, at least in my experience few programmers know Regular Expressions well. I would also not call regexes a programming (language), as it is just way to encode character patterns. A highly recommended one, as regexes is an ultimate tool when one needs to lookup, match, replace text contents.
Actually regular expressions are not so complicated if one understands what they consist of…