模式[.NET味]
(?<=<\w+ [^<>]*?\w+=")(?!display:none)(?<mt>[^"<>]+)(?=")
Options:^and $ match at line breaks
Assert that the regex below can be matched, with the match ending at this position (positive lookbehind) «(?<=<\w+ [^<>]*?\w+=")»
Match the character 「<」 literally «<»
Match a single character that is a 「word character」 (letters, digits, and underscores) «\w+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the character 「 」 literally « »
Match a single character NOT present in the list 「<>」 «[^<>]*?»
Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
Match a single character that is a 「word character」 (letters, digits, and underscores) «\w+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the characters 「="」 literally «="»
Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!display:none)»
Match the characters 「display:none」 literally «display:none»
Match the regular expression below and capture its match into backreference with name 「mt」 «(?<mt>[^"<>]+)»
Match a single character NOT present in the list 「"<>」 «[^"<>]+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Assert that the regex below can be matched, starting at this position (positive lookahead) «(?=")»
Match the character 「"」 literally «"»
圖案[ PCRE]
<!--
(<\w+ [^<>]*?\w+=")(?!display:none)([^"<>]+)(?=")
Options:^and $ match at line breaks
Match the regular expression below and capture its match into backreference number 1 «(<\w+ [^<>]*?\w+=")»
Match the character 「<」 literally «<»
Match a single character that is a 「word character」 (letters, digits, and underscores) «\w+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the character 「 」 literally « »
Match a single character NOT present in the list 「<>」 «[^<>]*?»
Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
Match a single character that is a 「word character」 (letters, digits, and underscores) «\w+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the characters 「="」 literally «="»
Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!display:none)»
Match the characters 「display:none」 literally «display:none»
Match the regular expression below and capture its match into backreference number 2 «([^"<>]+)»
Match a single character NOT present in the list 「"<>」 «[^"<>]+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Assert that the regex below can be matched, starting at this position (positive lookahead) «(?=")»
Match the character 「"」 literally «"»
[正則表達式解析什麼,但瑣碎的HTML時要使用一個非常糟糕的工具。(http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self -contained-tags) – 2012-04-18 05:22:44
您想要服務器端解決方案還是客戶端解決方案? – 2012-04-18 05:26:49
你想怎麼做?一種方法是使用[xpath](http://www.w3schools.com/xpath/) – 2012-04-18 05:37:53