How to take shortcode and content separately from a page?

I found the solution. I used the following codes and it worked for me . To remove the shortcode from the content, I Used this
<?php
$content = get_the_content();
$content = preg_replace("/\[.*]/m", " ", $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
?>

and the following code to get the shortcode only from post content

<?php
$pattern = get_shortcode_regex();
$matches = array();
preg_match_all("/$pattern/s", get_the_content(), $matches);
echo preg_replace_callback( "/$pattern/s", 'do_shortcode_tag', $matches[0][0] );
?>