HTML 파일에서 링크 텍스트를 검색하려고합니다. 각 링크에는 특정 클래스가 적용되지만 URL은 다릅니다. 내가 원하는 것보다 나는 다음과 같은 PHP 코드를 사용하고A 태그 사이의 텍스트 검색
...
<a class="fetch-me" href="products/1">Find ME!!!</a>
...
<a class="fetch-me" href="products/2">Me too!</a>
...
하지만 항상 더 받고 :
나는 다음이
preg_match_all('<a class="fetch-me" href=".*">(.*)</a>)siU', $string, $matching_data);
html을 정규식으로 구문 분석하지 마십시오. 네가 그렇게한다면, 척 노리스가 너를 사냥 할거야! http://stackoverflow.com/questions/590747/using-regular-expressions-to-parse-html-why-not – johnnyArt
스택 오버플로에 대한 다른 정규 표현식 질문과 중복되지 않습니까? –
예. 그리고 누군가가 그것을해야하기 때문에 : http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags –