From a03e6903d04600b7055ae4663a727753831dadcd Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 7 Aug 2017 14:31:34 +0000 Subject: [PATCH] B2017-168 Fixed logic to handle Fortran Formatted numbers --- PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs index 41ce280c..531d0e60 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs @@ -783,19 +783,25 @@ namespace VEPROMS.CSLA.Library } private string DoFortranFormat(string text) { - if (text.IndexOf(@".E") < 0) return text; + //if (text.IndexOf(@".E") < 0) return text; // Look for text as n.Ey, where n can be null or a number, and y can be // positive or negative. This translates into nx10x10y where y is // superscripted. For example, .E3 -> x103 where 3 is superscripted // and 10.E5 -> 10x10-5 where 5 is superscripted - string pat = @"(\d*).E([+-]*\d+)"; + // B2017-168 Fixed Regular Expression to cover more examples + // +1.25E6 1.25E6 -1.25E6 +2.E6 2.E6 -2.E6 +1.E6 1.E6 -1.E6 .E2 + string pat = @"(\d*\.\d*)E(([-+]|\\u8209\?)?\d+)"; string retstr = text; // for each one that needs translated: foreach (Match m in Regex.Matches(text, pat)) { string fnum = m.Groups[1].Value; string supnum = m.Groups[2].Value; - string newstr = string.Format(@"{0}x10\up2 {1}\up0 ", fnum, supnum); + string newstr; + if (fnum == "1.0" || fnum == "1." || fnum == ".") + newstr = string.Format(@"10\up2 {0}\up0 ", supnum); + else + newstr = string.Format(@"{0}x10\up2 {1}\up0 ", fnum, supnum); retstr = retstr.Replace(m.Value, newstr); } return retstr;