preg_match 를 통해 정규식 사용해서 문자열을 찾는데요
본문
내용 중 href="xxxxxx" 주소를 추출하려고 아래와 같이 정규식을 만들었습니다.
<link rel="alternate" type="application/xml+oembed" href="https://www.aaa.co.kr/plugins/post/oembed.xml/?url=https%3A%2F%2Fwww.tibrao.co.kr%2Fdy%2Fposting%2F13259426435161" title="vbd1;영 - #cosko ĵ댏" />
preg_match('/oembed"\shref=(.*?)title/', $snoopy->results, $text);
echo $text[1];
문서 상에
oembed 이라는 문자열이 2개 있는데 원하는 주소가 첫번째에 있어서 추출 성공하였는데요
preg_match 시작점을 xml+oembed" href= xml+ 추가해서 진행하려는데요
어떻게 표시해야 할지 ??
preg_match('/xml+oembed"\shref=(.*?)title/', $snoopy->results, $text);
매칭 되는것이 없는 듯...아무것도 출력되지 않아서..
답변 2
href 안에 있는 내용을 추출하려고 하는거죠?
preg_match('~<link[^>]+href="([^"]+)~is', $snoopy->results, $text);
이렇게 하시면 됩니다.
xml\+oembed[^>]+href="([^"]+)
그럼 이렇게 하세요
답변을 작성하시기 전에 로그인 해주세요.