added unicode dash to regular expression check for Fortran format numbers

This commit is contained in:
John Jenko 2011-10-12 12:43:51 +00:00
parent 9e010a2168
commit eed402ef7f

View File

@ -929,8 +929,14 @@ namespace VEPROMS.CSLA.Library
#region FortranFormat #region FortranFormat
public static string ConvertFortranFormatToScienctificNotation(string str) public static string ConvertFortranFormatToScienctificNotation(string str)
{ {
str = str.Replace(@"\u8209?", "-"); // ([+-]?|\\u8209\?) either an optional single character Plus (+) or Minus (-) or non-breaking dash (\u8209?)
string retval = Regex.Replace(str, "([+-]?)([0-9]+)[.]([0-9]*?)0*E([+-]?[0-9]+)", new MatchEvaluator(FixFortranNumber)); // ([0-9]+) a group of at least one digits
// [.] a decimal point
// ([0-9]*?) a group of zero or more digits
// 0*E optional zeros (spare zeros) followed
// ([+-]?|\\u8209\?) either an optional single character Plus (+) or Minus (-) or non-breaking dash (\u8209?)
// ([0-9]+) a group of at least one digits
string retval = Regex.Replace(str, @"([+-]?|\\u8209\?)([0-9]+)[.]([0-9]*?)0*E([+-]?|\\u8209\?)([0-9]+)", new MatchEvaluator(FixFortranNumber));
retval = Regex.Replace(retval, "[#](.*?)[#]", "\\up2 $1\\up0 ");// DOS Superscript retval = Regex.Replace(retval, "[#](.*?)[#]", "\\up2 $1\\up0 ");// DOS Superscript
retval = Regex.Replace(retval, "[~](.*?)[~]", "\\dn2 $1\\up0 ");// DOS Subscript retval = Regex.Replace(retval, "[~](.*?)[~]", "\\dn2 $1\\up0 ");// DOS Subscript
return retval; return retval;
@ -946,7 +952,7 @@ namespace VEPROMS.CSLA.Library
else // A number with a decimal point else // A number with a decimal point
sb.Append(match.Groups[2].Value + "." + match.Groups[3].Value + "x10"); sb.Append(match.Groups[2].Value + "." + match.Groups[3].Value + "x10");
// Add the exponent as superscript // Add the exponent as superscript
return sb.ToString() + "\\up2 " + match.Groups[4].Value.Replace("-",@"\u8209?") + "\\up0 "; return sb.ToString() + "\\up2 " + match.Groups[4].Value.Replace("-",@"\u8209?") + match.Groups[5].Value + "\\up0 ";
} }
#endregion #endregion
} }