Truncating words in anywhere can cause that potentially offensive or unpleasant words be displayed. With WordWrap function, this Regexp will keep the text within the desired box, but truncating only whole words.
I will use it in a project that demands that the truncated texts don't break apart within words.
About line 296 on trnuk8.js, I'm not actually proud of it, but I could only see this solution for reversing the string and then reversing back after applying the regex.
Truncating words in anywhere can cause that potentially offensive or unpleasant words be displayed. With WordWrap function, this Regexp will keep the text within the desired box, but truncating only whole words. I will use it in a project that demands that the truncated texts don't break apart within words.
About line 296 on
trnuk8.js
, I'm not actually proud of it, but I could only see this solution for reversing the string and then reversing back after applying the regex.