How to display quote format by preg_match function?

I have defined quote post format for the theme:

// Add post-formats for theme
add_theme_support( 'post-formats', array(
        'quote',
) );

After it, I want to display quote from the content. For that, I want to use preg_match_all function to search for blockquoteHello World./blockquote

if( $format == 'quote' ) {

    $content = apply_filters( 'the_content', get_the_content() );
    preg_match( '/blockquote.*?/', $content, $matches );
}

But it is not working. I want to find blockquote tag and display content inside this tag.

Topic post-formats Wordpress

Category Web


Meta-character . match any character except newline. If you have new lines inside quote, try this:

preg_match_all( '#<blockquote.*?>([\s\S]*?)</blockquote>#', $content, $matches );

Escape sequences:

\s - any whitespace character
\S - any character that is not a whitespace character


Try this code and if there is any class with blockquote then add in this code:

preg_match_all( '/<blockquote>(.*?)<\/blockquote>/', $content, $matches );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.