php - Get all of the text from a string after the first one sentence -


so using code first sentence out of string

preg_match('/^([^.!?]*[\.!?]+){0,1}/', $text, $abstract); 

can please me on how create regular expression remaining text or text after first sentence ?

thanks

this should give general idea using explode():

<?php $string = 'sentence one. sentence two. sentence three. sentence four.'; $sentences = explode(".", $string); echo $sentences[0]; // echos 'sentence one' echo $sentences[1]; // echos ' sentence two' echo $sentences[2]; // echos ' sentence three' echo $sentences[3]; // echos ' sentence four' // following demonstrates how you're asking, i'm not quite    // sure specific use case adapt necessary. echo $sentences[0]; // echos 'sentence one' // echo remaining sentences // start @ 1 not 0 skip first sentence ($i = 1; $i < count($sentences); $i++) {     echo $sentences[$i]; } 

note treat '.' end of sentence may not suitable in cases, example if have 'i.t.' mid-sentence. therefore regular expression may more appropriate solution if need level of accuracy. let me know if have questions. : )


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -