I need to match php variable but not method call, not inside single quote and not if $ is escaped.
is should match:
'foo $bar baz'
You can use this regex in PCRE with verbs
'[^'\\]*(?:\\.[^'\\]*)*' # will match text between single quotes skipping escaped quotes (*SKIP)(*F) # skips above single quoted text (?<!\\) # negative lookbehind to fail the match is $ is preceded by \ [a-zA-Z_]\w* # will match a variable starting with $, \b is for word boundary (?!->) # negative lookahead to fail the match if -> is at next position