<script type="text/javascript"> var myString = "123456789"; var mySplitResult = myString.split("5"); document.write("The first element is " + mySplitResult[0]); document.write(" The second element is " + mySplitResult[1]); </script>
The first element is 1234 The second element is 6789
<script type="text/javascript">
var cars = 'bmw,audi,honda,chrysler';
var split_cars = cars.split(',');
for (var i = 0; i < split_cars.length; i++) {
document.write(split_cars[i] + '
'); // print all words
}
</script>
bmw audi honda chrysler
Refer site:
http://www.w3schools.com/jsref/jsref_split.asp
http://www.alexxoid.com/blog/dev/javascript-dev/how-to-explode-the-string-in-javascript.html
Thanks,
ReplyDeleteIt's worked for me.
Regards,
Sardeep