<?php
$string = 'Hello, my name is "{{ @sql(SELECT TOP 1 name FROM table1 WHERE [id] = 5 ) }}" and my title is "{{ @sql(SELECT TOP 1 title FROM table1 WHERE [id] = 5 ) }}"';

$regex = '~
			\{{2}\h*@sql\(    # start of outer part
			(?P<query>[^()]+) # inner query
			\)\h*\}{2}        # end of outer part
		~x';

$string = preg_replace($regex, '$1', $string);
echo $string;
?>