<? $text=<<<TEXT "asdf.asdf,asdf!asdf TEXT; $words = preg_split('/[",.!\s]/', $text, -1, PREG_SPLIT_NO_EMPTY); print 'There are ' . count($words) .' words in the text.'; ?>