2017-01-10 2 views
-4

href = "download.php? id = 469979"this "OutDaughtered.S02E03.A.Quint.In.Crisis.720p.TLC.WEBRip.AAC2.0.x264- 난이 오류가HTML을 Regex로 변환하는 방법

# Search for filename 
my $match_filename=qr/<a class="index" href="download.php\/.*?\/.*?.torrent"><font color=.*?>(.*?).torrent<\/font><\/a> .Press/ms; 
my $filename_matches=$r->match('filename', $match_filename); 
if($filename_matches==0){ $r->err('Can not continue without filename, aborting!'); return 0;} 
my [email protected]$filename_matches[0]; 
$r->err("Filename: $filename"); 

: BTW.torrent "

<a class="index" href="download.php?id=469979"><img src="styles/images/download.png" style="position:relative;bottom:1px;" alt="Download" border="0"> OutDaughtered.S02E03.A.Quint.In.Crisis.720p.TLC.WEBRip.AAC2.0.x264-BTW.torrent</a> 

는이 코드를

Failed to match filename 
Can not continue without filename, aborting! 

감사

+0

지금 뭐라고 말합니까? 당신이 원하는 것은 무엇입니까, 당신은 왜 그것을하고 싶은가요, 그리고 당신은 어떤 결과를 얻고 싶습니까? – junkfoodjunkie

+0

당신이 실제로 묻는 것이 불분명합니다. "html을 정규 표현식으로 변환"한다는 것은 무엇을 의미합니까? 정규식은 _search_ 패턴이고, html은 마크 업 코드입니다. 그들은 공통점이 없습니다. 서로를 "변형"할 수는 없습니다. – arkascha

+0

어쩌면 그 코드와 일치 할 수있는 정규식을 원할 것입니까? 설명을 부탁드립니다. –

답변

0

PHP 코드 :

<?php 
$re = '/(?<=">\s)(?:.*)(?=<)/m'; 
$str = '<a class="index" href="download.php?id=469979"><img src="styles/images/download.png" style="position:relative;bottom:1px;" alt="Download" border="0"> OutDaughtered.S02E03.A.Quint.In.Crisis.720p.TLC.WEBRip.AAC2.0.x264-BTW.torrent</a> 
'; 

preg_match_all($re, $str, $matches); 

// Print the entire match result 
print_r($matches); 
?> 

정규 표현식 :

/(?<=">\s)(?:.*)(?=<)/m 

결과 :

Array 
(
    [0] => Array 
     (
      [0] => OutDaughtered.S02E03.A.Quint.In.Crisis.720p.TLC.WEBRip.AAC2.0.x264-BTW.torrent 
     ) 

) 

참조 : https://regex101.com/r/vYGgJz/1

+0

에서이 .torrent 파일을 추출합니다.이 href = "download.php? id = 469979" –

+0

에서이 토렌트 파일을 추출합니다. 태그없이 텍스트를 추출합니다. . –

관련 문제