See http://jsfiddle.net/wp5kw/
Assuming a paragraph of:
<p id="para"> This is a test. Is it? Yes, it is indeed!
You might ask, is this a sentence? To which I would reply
with a resounding "YES"!!!</p>
To grab all the sentences, use:
var sentences=$('#para').text() // get example text
.match(/[^\.\!\?]+[\.\!\?]+/g) // extract all sentences
.map(function(s){ // (optional) remove leading and trailing whitespace
return s.replace(/^\s+|\s+$/g,'');
});
To highlight the first sentence, use:
var count=0;
$('#para2').html(
$('#para')
.text()
.match(/[^\.\!\?]+[\.\!\?]+/g)
.map(function(s){
s=s.replace(/^\s+|\s+$/g,'');
return count++
? s
: '<span style="color:red">'+s+'</span>'
}).join(' ')
);
The regular expression assumes that periods, exclamation and question marks are used to terminate a sentence, and is:
[^\.\!\?]+ -- one or more non-sentence terminals
[\.\!\?]+ -- followed by one or more sentence terminals