Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm currently trying to write a string to a 'set load script' block and am attempting to cleanse the string before insertion into the load. My struggle is getting a string such as "hello','world" to load correctly, but when it is sent to the load script, the single quotes affect the script.
So I am trying to replace the " ' " character with U+2019 ( ’ ), but the single quote also seems to affect the replace function in automations. I attempted to escape the character in the function but then it doesn't do the replace.
Expected behavior:
{$.inputs.form.fqbnp} = hello','world
{replace: {$.inputs.form.fqbnp}, ''', '’'}
Output should be: hello’,’world
But is instead: {replace: hello','world, '''', '’'} as a string
So my question is, how do I 'cleanse' a string/have it as a literal string when used in a load script. How do I reference a comma for replacement in QAA.
This is what the 'Replace' dialog looks like in the UI when I create it:
And then when I confirm, and 'Edit Formula' again on it, it changes to this:
Many thanks!
Hi @André
I have done this using a custom code block.
There might be other simpler methods to solve this using the existing formula.
For now, try the automation shared below and let me know your feedback.
Thanks
Bump 👀
Can you share me your Automation Json and also the exact output you require. Sorry but i couldn't understand your requirement properly..
Hi @André
I have done this using a custom code block.
There might be other simpler methods to solve this using the existing formula.
For now, try the automation shared below and let me know your feedback.
Thanks
This is perfect, can't believe I didn't think about the custom code block! Thank you! 😊
Hello @AfeefaTk ,
Do you plan to correct this bug ? Use a custom code block to replace character is a little bit complicated no ?
Thanks for your code, I've been trying to replace a \ for 1 hour 😨
Paul
care to share your code (i know its a few months old) - been trying to replace \ in a variable (a json structure) with \\ for an hour now myself
It's attached to AfeefaTk's solution above.