JavaScript regular expression to match a comma delimited list
This method uses the JavaScript String’s match() method to parse a comma delimited list and show its content in a Panel control.
You can try it here http://jsfiddle.net/38tXU/
function parseList(list) { var reg = list.match(/\w+(,\w+)*/g); document.getElementById('pnl').innerHTML = 'Total length:' + reg.length + '<br />'; for (var i = 0; i < reg.length; i++) { document.getElementById('pnl').innerHTML += 'Token:\'' + reg[i] + '\'<br />'; } } //Call parseList function parseList('item1, item2, item3');
Comments (4)
This is my first time visit at here and I am actually happy to read everything at single place. Thank you!
I am now not positive the place you are getting your info, however great topic. I must spend a while studying much more or understanding more. Thanks for magnificent info I used to be on the lookout for this information for my mission.
Article writing is also a fun, if you know then you can write if not it is complex to write.
Hello! I know this is kind of off topic but I was wondering which blog platform are you using for this site? I’m getting sick and tired of WordPress because I’ve had problems with hackers and I’m looking at options for another platform. I would be great if you could point me in the direction of a good platform.