137
rated 0 times
[
142]
[
5]
/ answers: 1 / hits: 17335
/ 12 Years ago, tue, october 30, 2012, 12:00:00
I'm trying to return the first 5 words of a string in a readable format, no or commas separating words. I'm not sure if its a regex thing or what, but I can't figure it out although its probably simple. Thanks!
See what I have thus far:
http://jsfiddle.net/ccnokes/GktTd/
This is the function I'm using:
function getWords(string){
var words = string.split(/s+/).slice(1,5);
return words;
}
More From » jquery