RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Feet-inch to Decimal
Expression
(?:(?:(?<Feet>\d+)[ ]*(?:'|ft)){0,1}[ ]*(?<Inches>\d*(?![/\w])){0,1}(?:[ ,\-]){0,1}(?<Fraction>(?<FracNum>\d*)\/(?<FracDem>\d*)){0,1}(?<Decimal>\.\d*){0,1}(?:\x22| in))|(?:(?<Feet>\d+)[ ]*(?:'|ft)[ ]*){1}
Description
I needed an expression that would break down a written measurement, like 12' 2-15/16", into groups of feet, inches, fractional inches (num/dem). This is a modified expression based on Trevor Braun's orginal regex. Added the "ft" & "in" suffixes and the fraction's Numerator & Denominator groups.
Matches
1ft 2-3/4 in, 2' 3 4/5", 3ft, 4', 5 in, 6", 7.125 in, 3ft 4.5 in
Non-Matches
1ft 2-3/4in, 4in
Author Rating: Not yet rated. Normand Frechette
Source RegExLib.com
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: 6 1/4'
Name: Art Chereiski
Date: 11/2/2012 1:09:44 AM
Comment:
what about 6 1/4' ? It does not get parsed or is the expression incorrect?


Title: 6 1/4'
Name: Art Chereiski
Date: 11/2/2012 1:07:17 AM
Comment:
what about 6 1/4' ? It does not get parsed or is the expression incorrect?


Title: 6 1/4'
Name: Art Chereiski
Date: 11/2/2012 1:07:06 AM
Comment:
what about 6 1/4' ? It does not get parsed or is the expression incorrect?


Copyright © 2001-2014, RegexAdvice.com | ASP.NET Tutorials