Parsing expressions (any nice functions available?)
I'm making an MP3 file organiser.
I want to be able parse various expressions relating to either rules, or naming methods for my files.
An example of a rule might be the following:
%FileName% = %IDTagArtist% - %IDTagTitle%
A file that satisfies this rule could be the following:
My Artist - Track Title.mp3
with the IDTags for the artist and title set as "My Artist" and "Track Title" respectivly.
In C++ i'd be able to do this very easily, using IOStreams, are there any functions in the .net framework that would help me in any way with this task (such as things like inserting variables into strings when a 'n%' or whatever is encountered)?
Cheers for any replies.
Re: Parsing expressions (any nice functions available?)
Quote:
such as things like inserting variables into strings when a 'n%' or whatever is encountered
well, there are a few ways to go about it - am I'm unsure how you are doing it - so here goes:
String.Replace is one option:
string fileName = string.Replace("%artistName%",artistName);
String.Format is another option:
string artistName = "Led Zepplin";
string trackName = "Over the hills";
string fileName = string.Format("{0} - {1}", artistName, trackName);
Re: Parsing expressions (any nice functions available?)
That string.Format looks like what i want. Cheers.
Don't suppose there's anything for doing the revserse?
e.g. having a filename like:
Led Zepplin - Over The Hills.mp3
and getting the artist / title
Re: Parsing expressions (any nice functions available?)
I would think you would need to use Regular Expressions.