Skip to content

Commit 7f29924

Browse files
committed
Trim input in TryParseFeetInches()
1 parent 6b1d653 commit 7f29924

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

UnitsNet.Tests/CustomCode/LengthTests.FeetInches.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public void FeetInchesRoundTrip()
5454
[InlineData("1″", 0.08333333)] // Inches only
5555
[InlineData("1' 1\"", 1.08333333)] // Normal form
5656
[InlineData("1′ 1″", 1.08333333)] // Normal form
57+
[InlineData(" 1′ 1″ ", 1.08333333)] // Normal form, requires trimming
5758
[InlineData("1'1\"", 1.08333333)] // Without space
5859
[InlineData("1′1″", 1.08333333)] // Without space
5960
[InlineData("1 ft 1 in", 1.08333333)]

UnitsNet/CustomCode/Quantities/Length.extra.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public static bool TryParseFeetInches(string str, out Length result, IFormatProv
114114
// Match entire string exactly
115115
string pattern = $@"^(?<feet>{footRegex})\s?(?<inches>{inchRegex})$";
116116

117-
var match = new Regex(pattern, RegexOptions.Singleline).Match(str);
117+
var match = new Regex(pattern, RegexOptions.Singleline).Match(str.Trim());
118118
if (!match.Success) return false;
119119

120120
var feetGroup = match.Groups["feet"];

0 commit comments

Comments
 (0)