// regex to remove hashtag from string function remove_hashtag($text) { return preg_replace('/#\S+ */', '', $text); } // http://stackoverflow.com/questions/26478194/regex-to-remove-hashtag-from-string