C
Carl Cunningham
Hi folks,
I'm going bonkers with what should be a simple problem. I'm trying to change
this text (don't worry about <ul> & </ul>, I've got that taken care of):
<p>Bla bla</p>
<p>- dis dat (hjkhjk) </p>
<p>- DIS DAT</p>
<p>Bla bla</p>
into:
<p> Bla bla</p>
<li>- dis dat </li>
<li>- DIS DAT</li>
<p> Bla bla</p>
This script seems to work fine (keep an eye on the parenthesis):
-------------------------------------
$text = "<p>Bla bla</p>
<p>- dis dat </p>
<p>- DIS DAT</p>
<p>Bla bla</p>
" ;
@a = ($text =~ m/(<p>-.*?<\/p>)/sg) ;
foreach $temp (@a) {
$temp2 = $temp ;
$temp =~ s/p>-|p>/li>/g ;
$text =~ s"$temp2"$temp" ;
}
print $text ;
-------------------------------------
But if the text to be matched contains parenthesis:
$text = "<p>Bla bla</p>
<p>- dis dat (hjkhjk) </p>
<p>- DIS DAT</p>
<p>Bla bla</p>
" ;
The "m/expression/" matches the desired lines, but the s/// operator doesn't
match the line containing the parenthesis.
Could somebody puh-leaze help me on this?
I'm going bonkers with what should be a simple problem. I'm trying to change
this text (don't worry about <ul> & </ul>, I've got that taken care of):
<p>Bla bla</p>
<p>- dis dat (hjkhjk) </p>
<p>- DIS DAT</p>
<p>Bla bla</p>
into:
<p> Bla bla</p>
<li>- dis dat </li>
<li>- DIS DAT</li>
<p> Bla bla</p>
This script seems to work fine (keep an eye on the parenthesis):
-------------------------------------
$text = "<p>Bla bla</p>
<p>- dis dat </p>
<p>- DIS DAT</p>
<p>Bla bla</p>
" ;
@a = ($text =~ m/(<p>-.*?<\/p>)/sg) ;
foreach $temp (@a) {
$temp2 = $temp ;
$temp =~ s/p>-|p>/li>/g ;
$text =~ s"$temp2"$temp" ;
}
print $text ;
-------------------------------------
But if the text to be matched contains parenthesis:
$text = "<p>Bla bla</p>
<p>- dis dat (hjkhjk) </p>
<p>- DIS DAT</p>
<p>Bla bla</p>
" ;
The "m/expression/" matches the desired lines, but the s/// operator doesn't
match the line containing the parenthesis.
Could somebody puh-leaze help me on this?