Find all PHP Variables with preg_match
问题 How can I find all PHP variables with preg_match . I made the following regular expression: $string = 'Hallo $var. blabla $var, $iam a var $varvarvar gfg djf jdfgjh fd $variable'; $instring = array(); preg_match_all('/\$(.*?)/', $string, $instring); print_r($instring); I just don't understand how regular expressions work. 回答1: \$(.*?) Is not the right regular expression to match a PHP variable name. Such a regular expression for a Variable Name is actually part of the PHP manual and given as