I'm trying to use preg_match to find php code statements in template files so I can convert them to a different syntax (smarty).
Executing the following example isn't producing any matches, can someone let me know what I'm doing wrong?
$test = '<?=$test?>';
preg_match( '/<?=$([a-z]+)?>/', $test, $code );
preg_match( '/<\?=\$([a-z]+)\?>/i', $test, $code );
Also you can safely omit the parenthesis there
preg_match( '/<\?=\$[a-z]+\?>/i', $test, $code );
You have to escape special chars, that are used in regular expressions. You can use preg_quote() for this purpose