extract shortcodes from string

Where is this string located ?
I know you wrote “without wordpress system” , but WordPress has a function get shortcode regex

If you really want to avoid it for some reason, the following example might help you :

// check the post for a short code 
function check_shortcode( $shortcode = NULL ) {

    $post_to_check = get_post( get_the_ID() );

    // Until we search, set false 
    $found = false;

    //  no short - FALSE
    if ( ! $shortcode ) {
        return $found;
    }

    // check the post content for the short code 
    if ( stripos( $post_to_check->post_content, '[' . $shortcode) !== FALSE ) {
        // we have found the short code
        $found = TRUE;
    }

    // return our final results 
    return $found;
}

Leave a Comment