0
나는 많은 HTML 덩어리를 가지고있다. 이와예상보다 많은 정규식 일치
:
~<div>(?:.*?)<a[\s]+[^>]*?href[\s]?=[\s"\']+(#_ftnref([0-9]+))["\']+.*?>(?:[^<]+|.*?)?</a>(.*?)</div>~si
나는이 캡처 오전 :
<div> </div><hr align="left" size="1" width="33%" /><div><p><a title="" href="#_ftnref1">[1]</a> This is not to suggest that there are only two possible arguments to be made in support of blah blah <em>blah</em>.</p></div>
을하지만! 이걸 원해요.
<div><p><a title="" href="#_ftnref1">[1]</a> This is not to suggest that there are only two possible arguments to be made in support of blah blah <em>blah</em>.</p></div>
도와 주시겠습니까?
PS : (?:)
은 ()
과는 달리 텍스트 캡쳐를 피하기 위해 사용됩니다. 왜냐하면 나는 반환 된 $ matches 배열이이 포스트에서 언급되지 않은 몇 가지 다른 정규 표현식에 대해 일관되게하기를 원한다.
하면 될까요 할'DOM'를 사용하여 : 어떤 대안 길이 제약 조건이 해결 될 수
</div>
포함 된 후 예를 들어
겠습니까 만 건너/한
div
일치 중지 이? – Passerbyhttp://stackoverflow.com/questions/3577641/how-to-parse-and-process-html-xml-with-php – nhahtdh
예, 괜찮습니다. 때로는 마크 업이 가비지이기 때문에 DOM이 적절하지 않습니다. –