Strip tags and punctuation

by  • September 8, 2011 • Uncategorized

I needed to remove all html tags and punctuation from a wordpress post title to pass into a bing search module today and this little regex bit along with strip_tags() did the job:

$title = preg_replace('/[^a-zA-Z0-9-\s]/', '', strip_tags(get_the_title()));

Wheeee!

Leave a Reply

Your email address will not be published. Required fields are marked *