Talk:GetWords

I had a look at GetWords today, and BC seems to have introduced a few things which can improve GetWords. I've always struggled with regex, so I was a pretty happy when this worked...

function YourAddOn:GetWords(str) local retVal = {}; for nxtW in string.gmatch( msg, "(%p*%w*%p*%w+)%s*" ) do   table.insert( retVal, nxtW ); end return( retVal ); end

That regex/pattern keeps integral punctuation with a word, as well as leading punctuation. So... ... would remain intact, but input such as... ...would have the trailing punctuation removed.
 * we've
 * sub-sub==section
 * $3.50
 * _under-score
 * #->a
 * yes...
 * pre-male,
 * Hey!!
 * ?Who?

But yeah, regex isn't one of my string points, so maybe someone could come up with a cleaner way to acheive that part. It's seems a bit too convoluted.

Kord 13:21, 4 March 2007 (EST)