<?php
// http://stackoverflow.com/q/32969465/5290909

$pattern = '@([#$])|[{}/]+@';
$text = '{$gallery#pager/collectionName/imageName/manual/no_effect/foo1/foo2/.../fooN}';

$result = preg_split($pattern, $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);

//Validate
$valid = ($result[0] == '$') && ($result[2] == '#');

if ($valid) {
	var_dump($result);
}

?>