perl помощь

Any discussions about UNIX OS (include Linux)

Moderator: sva

perl помощь

Postby Dmitri Zubko on Sun Jun 20, 2010 6:42 pm

Как вырезать такой блок целиком?
Code: Select all
<div class="постоянное_имя">
   <div ... </div>
   <div ... </div>
   <style ... </style>
</div>
Dmitri Zubko
 

Re: perl помощь

Postby Ivan Agarkov on Sun Jun 20, 2010 6:42 pm

$constname = "const_name";
$body =~ s/<div
class="$constname">\n\s+<div[^\/]+<\/div>\n\s+<div[^\/]+<\/div>\n\s+<style[^\/]+<\/style>\n\s+<\/div>//g;
Ivan Agarkov
 

Re: perl помощь

Postby Alexander Wolf on Sun Jun 20, 2010 6:42 pm

Могу предположить, что прокатит такое ($body содержит весь документ):
chomp($body);
$body =~ m/<div class="постоянное_имя">(.+)<\/style><\/div>/gi;
$chunk = "<div class="постоянное_имя">".$1."</style></div>";
Alexander Wolf
 


Return to UNIX

Who is online

Users browsing this forum: No registered users and 9 guests

cron