Here I am faced with an issue that I believe(or at least hope) was solved 1 million times already. What I got as the input is a string that represents a length of an object
The imperial string values are a little bit more complicated, so I used following expression:
string pattern = "(([0-9]+)')*\\s*-*\\s*(([0-9])*\\s*([0-9]/[0-9])*\")*";
Regex regex = new Regex( pattern );
Match match = regex.Match(sourceValue);
if( match.Success )
{
int feet = 0;
int.TryParse(match.Groups[2].Value, out feet);
int inch = 0;
int.TryParse(match.Groups[4].Value, out inch);
double fracturalInch = 0.0;
if (match.Groups[5].Value.Length == 3)
fracturalInch = (double)(match.Groups[5].Value[0] - '0') / (double)(match.Groups[5].Value[2] - '0');
resultValue = (feet * 12) + inch + fracturalInch;