Jump to content

Wanting to use characters between <p> tags


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)
)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.