Thanks @m0r7if3r for all your help. I don't think I would have figured out the Regex part.
This is the code I am using and it works:
function wp_strip_header_tags( $text ) {
$raw_excerpt = $text;
if ( '' == $text ) {
//Retrieve the post content.
$text = get_the_content('');
//remove shortcode tags from the given content.
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
}
$regex = '#(]*>)\s?(.*)?\s?()#';
$text = preg_replace($regex,'', $text);
/***Change the excerpt word count.***/
$excerpt_word_count = 60; //WP default is 55
$excerpt_length = apply_filters('excerpt_length', $excerpt_word_count);
/*** Change the excerpt ending.***/
$excerpt_end = '[...]'; //This is the WP default.
$excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end);
$excerpt = wp_trim_words( $text, $excerpt_length, $excerpt_more );
return apply_filters('wp_trim_excerpt', $excerpt, $raw_excerpt);
}
add_filter( 'get_the_excerpt', 'wp_strip_header_tags', 5);