Error Runeval when using a simple regex


#1

Hi,
I’m struggling with a regex, I have a string that contains a lot of \n , which I want to get rid of. So I use the replace method with storeEval as follows :
var r=storedVars['just'];r.replace(/\n/g,' ');r;
(just is the string previously stored )
So when I run the program I expect to get a string without any \n, but all I get is this error :

Error in runEval code: unterminated regular expression literal

When using any other regex, it works fine , but for this specific case, it does not.
Thanks for any help or advice,


#2

Can you please post the JSON code of the storeEval command that does not work - you find it in the Source (JSON) tab of Kantu.


#3

Thank you for your reply. Here is the code for an example :
“Commands”: [
{
“Command”: “store”,
“Target”: “\na lot of \n \n \n that need to be \n removed \n”,
“Value”: “s”
},
{
“Command”: “storeEval”,
“Target”: “var r=storedVars[‘s’];r.replace(/\n/g,’ ');”,
“Value”: “s”
},
{
“Command”: “echo”,
“Target”: “${s}”,
“Value”: “”
}
]


#4

Thanks. I see the issue now => we will debug it further.


#5

Hello,
it seems that the Kantu IDE has a hard time managing objects that contain linebreaks such as \n. Could you please tell me if this issue would be resolved in the next update , if possible ? And if so, when would that be? Thanks for understanding,


#6

Yes, we try to resolve it with the next update. The next beta version is planned at the end of this week already. So your bug report comes at a good time :wink: