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?

Link to comment
Share on other sites

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.