Try this:
preg_match_all('/(?<=__\(").*?(?="\))/s', $foo, $matches);
print_r($matches);
which means:
(?<= # start positive look behind
__\(" # match the characters '__("'
) # end positive look behind
.*? # match any character and repeat it zero or more times, reluctantly
(?= # start positive look ahead
"\) # match the characters '")'
) # end positive look ahead
EDIT
And as Greg mentioned: someone not too familiar with look-arounds, it might be more readable to leave them out. You then match everything: __("
, the string and ")
and wrap the regex that matches the string, .*?
, inside parenthesis to capture only those characters. You will then need to get your matches though $matches[1]
. A demo:
preg_match_all('/__\("(.*?)"\)/', $foo, $matches);
print_r($matches[1]);