// a 링크만 추출하기
preg_match_all("|<a[^>]+>(.*)</a>|U",$str,$out1, PREG_PATTERN_ORDER);
preg_match_all("|<a[^>]+>.*</a>|U",$str,$out2, PREG_PATTERN_ORDER);
preg_match_all("^<a.*<\/a>^U", $str, $out3);
// http 로 시작하는 것만추출
preg_match_all("((http)://[a-z0-9-]+.[][a-zA-Z0-9:&#@=_~%;?/.+-]+)",$str,$out4, PREG_PATTERN_ORDER);
// 이미지만 추출
preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $str, $out5);
echo "<pre>";
print_r ($out1);
print_r ($out1);
print_r ($out1);
print_r ($out1);
print_r ($out1);
print_r ($out1);
preg_match("((http)://[a-z0-9-]+.[][a-zA-Z0-9:&#@=_~%;?/.+-]+)", $item[description], $match);// http로 시작하는 것만 추출
preg_match("/<img[^>]*src="[\']?([^>\"']+)[\"']?[^>]*>/i",$item[description],$match);//이미지만 추출
preg_match("/http:\/\/.*\.(jp[e]?g|gif|png)/Ui",$item[description],$match);//처음 이미지만 추출
RSS뷰어제작시 본문에서 이미지 추출만 추출할때 사용
'PHP∵SCRIPT' 카테고리의 다른 글
번호 시작 1. tets 2.tets 11.test 추출 정렬 처리 (0) | 2013.12.31 |
---|---|
내용중 image 추출 처리 (0) | 2013.12.31 |
{include 파일명.php} 처리 (파일명 치환 처리) (0) | 2013.12.31 |
정규식 배열로 여러 개 동시 처리 (0) | 2013.12.31 |
php한글체크를 위한 정규표현식 (0) | 2013.12.31 |
ereg / eregi 오류 Function eregi() is deprecated in 처리 (0) | 2013.12.31 |
regex 정규식 예제 (0) | 2013.12.31 |
특수문자 없애는 정규표현식 (0) | 2013.12.31 |
댓글