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? Link to comment https://forums.phpfreaks.com/topic/182811-grabbing-song-titles-and-artists-from-tweets/ 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. Link to comment https://forums.phpfreaks.com/topic/182811-grabbing-song-titles-and-artists-from-tweets/#findComment-964890 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://#" Link to comment https://forums.phpfreaks.com/topic/182811-grabbing-song-titles-and-artists-from-tweets/#findComment-964899 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.