Hi I'm trying to split a string based on multiple delimiters.Below is the code
var data="- This, a sample string.";
var delimiters=[" ",".","-",","];
var myArray = new Array();
for(var i=0;i<delimiters.length;i++)
{
if(myArray == ''){
    myArray = data.split(delimiters[i])
}
else
{
    for(var j=0;j<myArray.length;j++){
        var tempArray = myArray[j].split(delimiters[i]);
        if(tempArray.length != 1){
            myArray.splice(j,1);
            var myArray = myArray.concat(tempArray);
        }
    }
}
}
console.log("info","String split using delimiters is  - "+ myArray); 
Below is the output that i get
a,sample,string,,,,This,
The output that i should get is
This
a
sample
string
I'm stuck here dont know where i am going wrong.Any help will be much appreciated.
 
     
     
     
    