Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript loop through delimited string

var str = 'Hello, World, etc';
var str_array = str.split(',');

for(var i = 0; i < str_array.length; i++) {
   // Trim the excess whitespace.
   str_array[i] = str_array[i].replace(/^s*/, "").replace(/s*$/, "");
   // Add additional code here, such as:
   alert(str_array[i]);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #loop #delimited #string
ADD COMMENT
Topic
Name
9+3 =