String.Format is a nifty little tool I use a lot in development.
I'm wondering if anyone has made a function yet to reverse it and I'm wondering what the cool implementations other people can come up with.
What do I mean by reversing it ? I mean extracting the values which have been formatted.
Basic example:
String.Format ("Hello there, {0} {1}, how you doing ??", "beautifull", "girl")
Renders:
Hello there, beautifull girl, how you doing ??
The output of the reverse string format should be:
beautifull and girl.
The input of the function:
The formatting string
The output of String.Format
The output of the function:
Can be a string array, or list of type x which also contains the type of data.
The challenge:
Doing this with the most beautifull working code in a .Net language ??
Extra points are given for efficiency of the code and for extracting the type of the formatted text.
Determining the Type of the formatted text:
String.Format can take different types of content and format them as a string represenation of a Date, Currency, Floating point number etc.
Examples
Extra
Seems like I didn't think things through enough, when there is no seperator text between 2 items like: {0}{1} or if there is seperator text which is also inside the variables it isn't possible to determine where 1 starts and another ends.
Proposed solution: if one of the items is used more then once with a seperator they can still be deduced.
If neither of the ajoining items are used again or with no spaces again, there isn't really a correct way to split these items apart.
In which case the function can either reject the input, or merge the 2 variables as 1.
Good luck to all those who take this challenge :)
How nice it is to claim to have found a bug in a mayor MS product used daily :)
When hitting xcopy /? you get the following:

The /D parameter is wrong.
It should be: /D:m-d-j