improve php variable regexp
add smarty mode