ASP - 정규식을 이용한 html 중 img 태그만 추출
제목 : 정규식을 이용한 html 중 img 태그만 추출
'**************************************************
'*** 정규식으로 이미지만 뽑아내기 제거
'**************************************************
Set regEx = New RegExp ' 정규식을 작성합니다.
regEx.IgnoreCase = True ' 대/소문자 구분 안함을 설정합니다.
regEx.Global = True ' 전역을 설정합니다.
''' 1. 이미지 태그만 가져오기
regEx.Pattern = "<img [^<>]*>" ' 패턴을 설정합니다.
Set Matches = regEx.Execute(html) ' 찾기를 실행합니다.
RetStr = ""
For Each Match in Matches ' Matches 컬렉션을 반복합니다.
RetStr = RetStr & "<br>" & Replace(Match.Value, "<", "<") & vbcrlf
Next
Response.Write "1. 이미지 태그만 가져오기<br>" & RetStr & "<br><br><br>"
''' 2. 이미지 경로와 이미지명 가져오기
regEx.Pattern = "[^= ']*\.(gif|jpg|bmp)"
Set Matches = regEx.Execute(html) ' 찾기를 실행합니다.
RetStr = ""
For Each Match in Matches ' Matches 컬렉션을 반복합니다.
RetStr = RetStr & "<br>" & Match.Value & vbcrlf
Next
Response.Write "2. 이미지 경로와 이미지명 가져오기<br>" & RetStr & "<br><br><br>"
''' 3. 이미지명만 가져오기
regEx.Pattern = "[^= '/]*\.(gif|jpg|bmp)"
Set Matches = regEx.Execute(html) ' 찾기를 실행합니다.
RetStr = ""
For Each Match in Matches ' Matches 컬렉션을 반복합니다.
RetStr = RetStr & "<br>" & Match.Value & vbcrlf
Next
Response.Write "3. 이미지명만 가져오기<br>" & RetStr & "<br><br><br>"
내용 : html editor 로 넘어온 '내용' 글 중 img 태그만 추출 하는 것