Jump to content

Wanting to use characters between <p> tags


Modernvox

Recommended Posts

Hi guys.

 

I am wanting to scrape  just the link, title and location from each post: I have bolded the first one so you may see the text I want to get.

 

<p><a href="/muc/1529797723.html">rock band needs vocals -</a><font size="-1"> (ri)</font></p>

<p><a href="/muc/1529790821.html">bass player available -</a><font size="-1"> (newport area)</font></p>

 

Any help is appreciated.

 

 

Link to comment
https://forums.phpfreaks.com/topic/186648-wanting-to-use-characters-between-tags/
Share on other sites

This should work (I tested it with your provided example).

'/<a href="([^"]+)">([^<]+)<\/a><font size="-1">([^"]+)<\/font>/i'

 

This expression will return an array with 4 elements (if run through preg_match or preg_match_all):

Array
(
    [0] => <a href="/muc/1529797723.html">rock band needs vocals -</a><font size="-1"> (ri)</font> 
    [1] => /muc/1529797723.html
    [2] => rock band needs vocals -
    [3] =>  (ri)
)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.