- preg_match_all: documentation ( source)
<?php
$template = "select emp.* from employee emp" .
" join departments dep on emp.id_department = dep.id" .
" @{where}" .
" @{order}" .
" limit :limit offset :offset";
echo $template;
$pattern = '/[^\\$]\\@\\{(\\w+)\\}/';
preg_match_all($pattern, $str, $matches);