정규직 잘하시는분

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
정규직 잘하시는분

QA

정규직 잘하시는분

본문

<img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583018807.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583027195.jpg?0"  />

 

여기에서 

정규식 (.+?) 이렇게 썻는데  빨간볼드 ?0이부분 뺴고 가져올려면 정규직 (.+?) 여기에서 어떻게 쓰면되나요 ?

이 질문에 댓글 쓰기 :

답변 3

이렇게 해도 되는지 모르겠네요

 


<?php
$str = '<img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583018807.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583027195.jpg?0"  />';
preg_match_all("@src=\"(.*)\?0\"@U",$str,$matches);
print_r($matches);

 

Array
(
    [0] => Array
        (
            [0] => src="https://img.namedtoon.com/data/file/webtoon/1803/15266583018807.jpg?0"
            [1] => src="https://img.namedtoon.com/data/file/webtoon/1803/15266583027195.jpg?0"
        )

    [1] => Array
        (
            [0] => https://img.namedtoon.com/data/file/webtoon/1803/15266583018807.jpg
            [1] => https://img.namedtoon.com/data/file/webtoon/1803/15266583027195.jpg
        )

)

<div id="bo_v_con">
<div style="line-height:50%;"></div><div class="toonoverlay"></div>
<img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583010525.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583018807.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583027195.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583040969.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583049646.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583061123.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583072836.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583081254.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/1526658309054.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583099451.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583110941.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583122971.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583131635.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583143695.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583156324.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583163066.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583171142.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583179492.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583188777.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583202739.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583212225.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583220662.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583229245.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583237472.jpg?0"  /></div>
</div>

</section>



원소스는 이런데요 정규직 파싱해서
~rlay"></div>\s*(.+?)</div~isx 이러게 쓰는데 여기에결과갑이
<img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583188777.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583202739.jpg?0"  />

이런이미지가 여러개나오는데 ?0  요부분만뺴고
<img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583188777.jpg"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583202739.jpg"  />

이렇게 나오게할려구요

안녕하세요?

 

원하시는 방법이 아닐 수도 있겠지만

 

말씀하신대로 ?0을 제외한 결과물이 나오기는 하는 방법이네요~

 


<?php
$html = '</div><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583010525.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583018807.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583027195.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583040969.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583049646.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583061123.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583072836.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583081254.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/1526658309054.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583099451.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583110941.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583122971.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583131635.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583143695.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583156324.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583163066.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583171142.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583179492.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583188777.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583202739.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583212225.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583220662.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583229245.jpg?0"  /><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583237472.jpg?0"  /></div>';
preg_match_all('/<img(.*?)\.jpg/', $html, $imgtags);
foreach ($imgtags[0] as $imgtag)
    echo($imgtag.'">');
?>

 

결과물: 

<img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583010525.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583018807.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583027195.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583040969.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583049646.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583061123.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583072836.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583081254.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/1526658309054.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583099451.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583110941.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583122971.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583131635.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583143695.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583156324.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583163066.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583171142.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583179492.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583188777.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583202739.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583212225.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583220662.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583229245.jpg"><img src="https://img.namedtoon.com/data/file/webtoon/1803/15266583237472.jpg">

 

정규식만 사용한다면 배르만 님께서 말씀하신 방법에서

 

str_replace 대신에 preg_replace를 사용할 수도 있겠지만 전자가 속도 측면에서 유리하겠죠 ^^

 

그럼 좋은 오후 되세요~!

답변을 작성하시기 전에 로그인 해주세요.
전체 52
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT