This is a twitter, I need transform the string a an array, how to do make?, because I need to iterate through each element separately...
var twitter = 'RT Informacion sobre algo en comun @opmeitle #demodelor union J, http://bit.ly/a12, opmeitle@email.com';
I need something like that.
var result = ['RT, Informacion, sobre, algo, en, comun, @opmeitle, #demodelor, union, J, http://bit.ly/a12, opmeitle@email.com']
for ( i in result) { console.log(result[i]) } // output >>
RT
Informacion
sobre
...
use, javascript or nodeJs
It seems to me like you need something like this:
var string = "hi coldfusion stackoverflow";
var array = string.split(' ')
This code splits the string into an array through the argument passed into .split which in this case is a space, " ". When .split is executed, all the spaces (because we passed in a space) are removed and new elements(?) of an array are created in between the spaces.
// This splits result into words -- /\s+/ is a regex
// that detects one or more whitespace characters
var twitt = 'foo bar baz quux';
var result = twitt.split(/\s+/);
// result is now ['foo', 'bar', 'baz', 'quux']
for (var i = 0; i < result.length; i++) {
console.log(result[i]);
}
Avoid using for in loops to iterate over arrays.