Revision: 6930
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 25, 2008 11:35 by evanwalsh
Initial Code
function countSentences($str){ return preg_match_all('/[^\s](\.|\!|\?)(?!\w)/',$str,$match); } countSentences("This is a test. Hey!"); // returns 2 countSentences("What do you want?"); // returns 1 // etc.
Initial URL
Initial Description
This will count sentences that end in . or ? or ! and have a space after them.
Initial Title
Count sentences in a string
Initial Tags
regex, php, simple, function
Initial Language
PHP