Jump to content

Grabbing song titles and artists from tweets.


mattal999

Recommended Posts

Hi guys,

 

I have a question. I need to extract song titles and artists from recently posted tweets. Now I have the tweets, that's easy. I just need to extract these 2 values from it using regular expressions.

 

Now I've done some reading, and this is what I have:

 

preg_match('/(.*)(?=-|~|by)(.*)/i', $text, $song);
print_r($song);

 

Which obviously doesn't work as I want it to. Here is the output and the original:

 

Listening to: Welcome to Cinetropia mix by zetrik http://bit.ly/6KCB33 via #soundcloud TURNTABLISM GROUP.

 

Array (

    [0] => Listening to: Welcome to Cinetropia mix by zetrik http://bit.ly/6KCB33 via #soundcloud TURNTABLISM GROUP.

    [1] => Listening to: Welcome to Cinetropia mix

    [2] => by zetrik http://bit.ly/6KCB33 via #soundcloud TURNTABLISM GROUP.

)

 

Can you guys give me any help on what kind of regular expression I should go about doing?

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.