I have a chunk of HTML I don't know anything about I am trying to find and replace a value of a certain attribute in a certain tag. So I want to capture the entire tag that has my matching attribute. There can be any number of unknown attributes in the tag as well. Say that I have the following HTML (which is all on one line) where xxxx="zzzz" represents any number of unknown attributes. I want to capture only the meta tag that has content="320"
My problem is that im getting every metatag before the one that contains the actual attribute im looking for.
<meta charset="UTF-8"><meta name="apple-mobile-web-app-capable" xxxx="zzzz" content="yes"><meta name="apple-mobile-web-app-status-bar-style" xxxx="zzzz" content="default"><meta name="mobile-web-app-capable" xxxx="zzzz" content="yes"><meta name="HandheldFriendly" xxxx="zzzz" content="True"><meta name="MobileOptimized" xxxx="zzzz" content="[320]"><meta name="format-detection" xxxx="zzzz" content="telephone=no"><meta name="title" xxxx="zzzz" content="Regex101">
Formatted version as a visual aid:
<meta charset="UTF-8">
<meta name="apple-mobile-web-app-capable" xxxx="zzzz" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" xxxx="zzzz" content="default">
<meta name="mobile-web-app-capable" xxxx="zzzz" content="yes">
<meta name="HandheldFriendly" xxxx="zzzz" content="True">
<meta name="MobileOptimized" xxxx="zzzz" content="320">
<meta name="format-detection" xxxx="zzzz" content="telephone=no">
<meta name="title" xxxx="zzzz" content="Regex101">
This is the regex I am using <meta.*?\s+content\s*=\s*\"\[320]\".*?
example: http://refiddle.com/refiddles/5b10282175622d3008480000