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;
}'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html