mattal999 Posted November 24, 2009 Share Posted November 24, 2009 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? Quote Link to comment Share on other sites More sharing options...
mattal999 Posted November 24, 2009 Author Share Posted November 24, 2009 Oops, I forgot to post what output is ideal. Array ( [0] => Welcome to Cinetropia mix [1] => zetrik ) Or something along those lines. Quote Link to comment Share on other sites More sharing options...
cags Posted November 24, 2009 Share Posted November 24, 2009 Is the name always followed by a url? "#Listening to: (.+?) by (.+?) http://#" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.