Javascript examples for String Operation:String Split
Use RegExp in string split function
<html> <head></head> <body> <p id="answer"></p> <script> var foo = 'property:value property2:"value2" property3>"value3" -property4:"value4"'; arr = foo.split(/[-:<>\s]+/); str = ""; for (i = 0; i < arr.length; i+=2) { str = str + arr[i] + " : " + arr[i+1] + " <br>"; }//from w ww. ja v a 2 s .co m document.getElementById("answer").innerHTML = str; </script> </body> </html>