X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=inc%2Fsmarty%2Fplugins%2Fmodifier.count_sentences.php;fp=inc%2Fsmarty%2Fplugins%2Fmodifier.count_sentences.php;h=0c210f08fe97801fe36bc63847f00b69544f5387;hb=e586807dafc64c3fe152ab518599e6cf3f0f84e1;hp=0000000000000000000000000000000000000000;hpb=bc13d5d6e1834068f8b690c32bba114e352dacdd;p=mirrors%2FKyberia-bloodline.git diff --git a/inc/smarty/plugins/modifier.count_sentences.php b/inc/smarty/plugins/modifier.count_sentences.php new file mode 100644 index 0000000..0c210f0 --- /dev/null +++ b/inc/smarty/plugins/modifier.count_sentences.php @@ -0,0 +1,28 @@ + + * Name: count_sentences + * Purpose: count the number of sentences in a text + * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php + * count_sentences (Smarty online manual) + * @param string + * @return integer + */ +function smarty_modifier_count_sentences($string) +{ + // find periods with a word before but not after. + return preg_match_all('/[^\s]\.(?!\w)/', $string, $match); +} + +/* vim: set expandtab: */ + +?>