Say for example I have the following code:
My very long title
Another long title
If I wanted to
using some php and the mighty regular expressions
function formatHeadline($headline){
if(preg_match('/(\w+\s+){3}/', $subject, $match)){
return $match[1] . '...';
}
return $headline;
}
The same method should be possible in javascript using regex and jquery.
Jquery also have the ellipsis plugin, you might want to look into it.