Hi all,
I am trying to use regular expressions to parse out mp3 titles into
three different groups (artist, title and remix). I currently have
three ways to name a mp3 file:
Artist - Title [Remix]
Artist - Title (Remix)
Artist - Title
I have approached the problem the following way.
First I start by looking to see if the following regex matches (?
<artist>.*?) - (?<title>.*?) \[(?<remix>.*?)\]. If not I move on to
see if (?<artist>.*?) - (?<title>.*?) \((?<remix>.*?) \) matches. If
not I move on to see if (?<artist>.*?) - (?<title>.*?) matches,
however I run into two problems.
1. The last regex does not work.
2. I have to execute these regular expressions in the above order for
it to be correct. If I would execute a working version of the last
regex it would match every time.
So my two questions are:
1. Is there a better way to do this? Do I have to execute the regular
expressions in order for this to work? It could be problematic if I
introduce more naming conventions.
2. How do I get the last regular expression to work.
Any help is appreciated.
Thanks
I am trying to use regular expressions to parse out mp3 titles into
three different groups (artist, title and remix). I currently have
three ways to name a mp3 file:
Artist - Title [Remix]
Artist - Title (Remix)
Artist - Title
I have approached the problem the following way.
First I start by looking to see if the following regex matches (?
<artist>.*?) - (?<title>.*?) \[(?<remix>.*?)\]. If not I move on to
see if (?<artist>.*?) - (?<title>.*?) \((?<remix>.*?) \) matches. If
not I move on to see if (?<artist>.*?) - (?<title>.*?) matches,
however I run into two problems.
1. The last regex does not work.
2. I have to execute these regular expressions in the above order for
it to be correct. If I would execute a working version of the last
regex it would match every time.
So my two questions are:
1. Is there a better way to do this? Do I have to execute the regular
expressions in order for this to work? It could be problematic if I
introduce more naming conventions.
2. How do I get the last regular expression to work.
Any help is appreciated.
Thanks
Comment