Archi Forum

Archi Plug-ins => jArchi => Topic started by: William Malabry on February 12, 2022, 12:59:49 PM

Title: String split
Post by: William Malabry on February 12, 2022, 12:59:49 PM
I searched in the forum archives but didn't find an answer.
I want to split a string with a separator and get an array.

I tried the javascript String way :
myDate = '12/02/2022';
splittedDate = myDate.split('/');

But it does not work.
Apart from splitting with regular expressions, is there is a simple way to do this in jArchi ?

Thanks in advance for your help.

William
Title: Re: String split
Post by: Phil Beauvoir on February 12, 2022, 13:10:02 PM
JS split does work, but you have to treat the result as an array:

myDate = '12/02/2022';
splittedDate = myDate.split('/');
console.log(splittedDate[0]);
console.log(splittedDate[1]);
Title: Re: String split
Post by: William Malabry on February 12, 2022, 13:19:31 PM
In fact, I had two errors : using it as a non array value and one value to split was null which ended in a JS error...

Thank you very much Phil.