$re = '/(?<=var modelCode = ")(.+)(?=";)/m';
$str = 'var pageTrackName = digitalData.page.pageInfo.pageTrack;
if(pageTrackName == "product detail" || pageTrackName == "generic product details"){
var modelCode = "GT-P5100TSABTU";
var displayName = "Galaxy Tab 2 (10.1, 3G)".replace(/(<([^>]+)>)/gi, "");
digitalData.product.model_code = modelCode;
digitalData.product.displayName = displayName;
pageName += ":" + modelCode;
}';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php