mohtasham1983
May 12th, 2009, 07:45 PM
Hi,
I'm trying to extract some information from an html document using regular expression.
For example, I want to extract the "Results1" and "Results2" from a document that has the following information:
<li>
<b>Title1: </b>
Results1
</li>
<li>
<b>Title2: </b>
Results2
</li>
I use the following regular expression:
@\<li\>(.*)\</li\>@
This one returns everything inside the first <li> block. While I still need to extract everything inside the second <li> block.
That's why, to get the information inside the second block, I use the following regular expression:
@\<li\>\<b\>Title2: \</b\>(.*)\</li\>@
I think because the <b> tag comes in a new line after <li>, it's not able to find it. I searched on a lot of PHP regular expressions tutorial, but couldn't find any way to add new line to my regular expression.
Any idea how to eliminate my new line problem?
I'm trying to extract some information from an html document using regular expression.
For example, I want to extract the "Results1" and "Results2" from a document that has the following information:
<li>
<b>Title1: </b>
Results1
</li>
<li>
<b>Title2: </b>
Results2
</li>
I use the following regular expression:
@\<li\>(.*)\</li\>@
This one returns everything inside the first <li> block. While I still need to extract everything inside the second <li> block.
That's why, to get the information inside the second block, I use the following regular expression:
@\<li\>\<b\>Title2: \</b\>(.*)\</li\>@
I think because the <b> tag comes in a new line after <li>, it's not able to find it. I searched on a lot of PHP regular expressions tutorial, but couldn't find any way to add new line to my regular expression.
Any idea how to eliminate my new line problem?