preg match all for shortcode

I need to store this in my blog here

preg_match_all("/\/", string_page_content, $matches);

Piece of code to separate or to match shortcode ''

Which then i need to replace the string found

echo str_replace( $matches[0][0] , gallery($matches[0][0]) ,string_page_content );

for instance if i have function


function gallery($var){
echo 'THIS IS THE REPLACEMENT';
}

CategoriesIT