I'm totally out of luck with creating a working patternt to match for my preg_match.
What I would like to do is, create a pattern that will match sentenses in a bunch of text..

It should recognize a word that has a capital letter and take it as the start of sentese and then get all words till it hits . ? or !. so the patterns should contain A-Z a-z 0-9 , " ' and stop when it hits . ! or ? .. any help creating such pattern would be appriciated.

Thanks, Dusan

This matches a sentence as you've defined it. It will also match across multiple lines:

$rx = '/\b[A-Z].*[\.?!]/msU';
$testPhrases = "Alas, can I put time in a bottle? The quick brown \nfox jumps over the lazy dog.  Sally \nsells seashells by the seashore.";
$arFound = array();

$count = preg_match_all($rx, $testPhrases, $arFound);


Thanks a lot with your help, that is just what I was trying to do, it works perfect!

Thanks madCoder

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.