JavaScript と jquery を使用して、文を分離し、それらを 1 つずつ配列に格納しようとしています。これは私が試したものです
var sentenceArray = new Array();
//SPLITS PARAGRAPHS INTO SENTENCES//
$('#text').each(function() {
var sentences = $(this).html().replace(/([^.!?]*[^.!?\s][.!?]['"]?)(\s|$)/g,'<span class="sentence">$1</span>$2');
sentenceArray.push(sentences);
});
ただし、これは、配列の [0] インデックスに結合されたすべての文を返します。それらをどのように分離しますか?
<div id="text">
Crowds blocked main roads in Sao Paulo and Brasilia, and protesters confronted police in Rio de Janeiro state shortly after the U-turn was announced.
Earlier, there were clashes before Brazil's football team played Mexico in Fortaleza in the Confederations Cup.
Protesters are angry at corruption and high spending on next year's World Cup.
Activists say they have not changed their intention to hold the biggest demonstrations yet on Thursday.
The BBC's Julia Carneiro, in Sao Paulo, says hundreds of thousands are expected on the streets there before another round of matches in the Confederations Cup.
</div>