url 정규식 치환좀 도와주세요

url 정규식 치환좀 도와주세요

QA

url 정규식 치환좀 도와주세요

본문

게시판에서 wr_content를 변형하고있는데요.

 

a태그에서 url부분만 치환하려는데 정규식좀 알수있을까요??

 

www.naver.com/index.html , m.naver.com/index.html , naver.com/aaa/index.html

 

위와같은 주소를

 

아래와같이 바꾸고싶어요....

aaa.com/index.html , aaa.com/index.html , aaa.com/aaa/index.html

 

정규식은 젬뱅이라... ㅜ,.ㅠ

이 질문에 댓글 쓰기 :

답변 1


$str = 'sdfdf<a href="https://www.naver.com/index.html">www.naver.com</a>
, <a href="http://m.naver.com/index.html">index</a> , 
sdfsff<a href="http://naver.com/aaa/index.html">naver.com</a>xlk;vxvk';

preg_match_all("#<a\s+href=[\"\']([^\"\']+)[\"\']#", $str, $m);

print_r($m[1]);
답변을 작성하시기 전에 로그인 해주세요.
전체 220
QA 내용 검색

회원로그인

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