June 27th, 2013, 11:07 AM
Formatting output with RegEx
I use a RegEx pattern to check if an input string reflects a valid time (ie: "(?<h>2[0-3]|\d)\?<m>[0-5]\d)\?<s>[0-5]\d)"). I use to gather hours, minutes and seconds from the named groups and do my calculations.
This pattern is customizable as long as the groups are named h, m, and s as in my example.
Now I need to format my output against the same pattern so that if the user choose a format like 4h 11' 22" (instead of the standart hh:mm:ss) I should conform my output to their will.
How can I achieve this result?
Thanks for your help.
PS: I use .NET