Am looking to grab the tags from a form and save them to an array of strings to loop over. I would like the tags to be stripped of white spaces, # signs, and commas.
This is almost working, but tagArraySplit[i].replace(/#/g, ''); does not strip the '#'..
var newTags = $( "#newTags" ).val();
console.log(newTags);
// regex split for one or more commas or spaces
// so that multiple consecutive spaces or a comma+space .. are not empty
var tagArraySplit = newTags.split(/[ ,]+/).filter(Boolean);
var tags = [];
for (i=0; i<tagArraySplit.length; i++)
{
console.log(tagArraySplit[i]);
tagArraySplit[i].trim;
tagArraySplit[i].replace(/#/g, '');
console.log('trimmed a tag');
console.log(tagArraySplit[i]);
tags.push(tagArraySplit[i]);
}
console.log(tags);