/** * @param Review $review */ protected function cleanComment(Review $review) { $comment = $review->getComment(); $pattern = '/(#\\w+)/'; $replacement = ''; $comment = preg_replace($pattern, $replacement, $comment); $comment = preg_replace('!\\s+!', ' ', $comment); $review->setComment($comment); }