Showing posts with label Regex to remove track number from song name?. Show all posts
Showing posts with label Regex to remove track number from song name?. Show all posts

Wednesday, June 26, 2013

[android help] Regex to remove track number from song name?


Regex to remove track number from song name?



I have a ListView that display song names and artists. Sometimes, the song names contain the track number and a separator with some in this format



13 - J. Cole - Best Friend


and others like this



13 - Beautiful People


After some digging around I found that the best way to go about this is to define a regex pattern that will remove any unnecessary characters in the string. Cool. I've looked at other SO questions on a similar topic here and a couple blog posts but still no luck.


This my first time dealing with regular expressions and I find it quite useful, just trying to wrap my head around coming up with efficient/useful patterns.


Here's what I need to remove from the string if it is a match



The track number
The "-" or whatever separator character that follows it
The artist name and the "-" that follows that(Each artist name is listed below the song, so it would be redundant)


Any help on this would be greatly appreciated as usual guys, thanks!


Edit: The same output that I would like is something like this, with just the song names. No track numbers, and if applicable; no artist names following the "-"



Beautiful People
Angel of Mine
Human Nature


.

stackoverflow.comm

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...