preg_match_all 정규식을 쓰는데 내용에 $표시가 있으면 그 이후 내용이 짤립니다.

2015-12-02 (수) 16:51:33 3,646

아래와 같이 preg_match_all에 정규식을 써서 사용하려고 합니다.

preg_match_all('/<td align="left" bgcolor="#666666" style="padding:10px 10px 10px 10px" class="W">([^$]*)/', $html2, $matches, PREG_SET_ORDER); 

위와 같이 preg_match_all 을 쓰고 있는데 긁어올 내용에 $표시가 있으면 $표시 이후 내용이 짤립니다. 아마 정규식 또는 php 코드 $표시와 중복되서 뭔가 에러가 나는거 같은데 어떻게 수정하면 되나요?

Copy
$__s->fetch($surl);  $html=$__s->results;  $search2 = "images/dis_btmbg.gif";   $html2 = "";   if(strpos($html, $search2) !== false) {      $html2 = substr($html, 0, strpos($html, $search2));   }   preg_match_all('/<td align="left" bgcolor="#666666" style="padding:10px 10px 10px 10px" class="W">([^$]*)/', $html2, $matches, PREG_SET_ORDER);    echo $matches[0][1];
 

답변 1개

정규식 강좌를 참고하세요.

http://sir.co.kr/pg_lecture/185 

답변을 작성하려면 로그인이 필요합니다.