Workaround for commas in Lauris values.
- VERBESSERT: Kein Crash mehr, falls sich ein Komma in den Lauris-Block einschleicht.
This commit is contained in:
@ -104,24 +104,25 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
||||
// "Erythrozyten (U): + [negativ]"
|
||||
Match match;
|
||||
Regex numericalRegex = new Regex(
|
||||
@"(?<name>[^:]+):\s*(?<value>[\d.]+)\s*(?<limits>\[[^\]]+])?\s*(?<unit>[^;]+)?");
|
||||
@"(?<name>[^:]+):\s*(?<value>[\d,.]+)\s*(?<limits>\[[^\]]+])?\s*(?<unit>[^;]+)?");
|
||||
Regex categoricalRegex = new Regex(
|
||||
@"(?<name>[^:]+):\s*(?<value>[^[;]+)\s*(\[(?<normal>[^\]]+)])?");
|
||||
if (numericalRegex.IsMatch(LaurisText))
|
||||
{
|
||||
match = numericalRegex.Match(LaurisText);
|
||||
ParseLimits(match);
|
||||
Value = match.Groups["value"].Value.Trim().Replace(',', '.');
|
||||
}
|
||||
else
|
||||
{
|
||||
match = categoricalRegex.Match(LaurisText);
|
||||
Normal = match.Groups["normal"].Value.Trim();
|
||||
Value = match.Groups["value"].Value.Trim();
|
||||
}
|
||||
if (match != null)
|
||||
{
|
||||
OriginalName = match.Groups["name"].Value.Trim();
|
||||
Name = OriginalName;
|
||||
Value = match.Groups["value"].Value.Trim();
|
||||
Unit = match.Groups["unit"].Value.Trim();
|
||||
}
|
||||
}
|
||||
@ -135,14 +136,15 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
||||
{
|
||||
if (match.Groups["limits"].Success)
|
||||
{
|
||||
Regex limitRegex = new Regex(@"\[(?<limit1>[-\d.]+)?\s*(?<operator>\S+)\s*(?<limit2>[-\d.]+)?]");
|
||||
Regex limitRegex = new Regex(@"\[(?<limit1>[-\d,.]+)?\s*(?<operator>\S+)\s*(?<limit2>[-\d,.]+)?]");
|
||||
Match limitMatch = limitRegex.Match(match.Groups["limits"].Value);
|
||||
if (limitMatch.Groups["limit1"].Success && limitMatch.Groups["limit2"].Success)
|
||||
{
|
||||
// Use InvariantCulture because Lauris always outputs dots as decimal separator
|
||||
LowerLimit = Double.Parse(limitMatch.Groups["limit1"].Value,
|
||||
// Only in rare cases, a comma sneaks in...
|
||||
LowerLimit = Double.Parse(limitMatch.Groups["limit1"].Value.Replace(',', '.'),
|
||||
CultureInfo.InvariantCulture);
|
||||
UpperLimit = Double.Parse(limitMatch.Groups["limit2"].Value,
|
||||
UpperLimit = Double.Parse(limitMatch.Groups["limit2"].Value.Replace(',', '.'),
|
||||
CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
@ -150,11 +152,11 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
||||
switch (limitMatch.Groups["operator"].Value.Trim())
|
||||
{
|
||||
case "<=":
|
||||
UpperLimit = Double.Parse(limitMatch.Groups["limit2"].Value,
|
||||
UpperLimit = Double.Parse(limitMatch.Groups["limit2"].Value.Replace(',', '.'),
|
||||
CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case ">=":
|
||||
LowerLimit = Double.Parse(limitMatch.Groups["limit2"].Value,
|
||||
LowerLimit = Double.Parse(limitMatch.Groups["limit2"].Value.Replace(',', '.'),
|
||||
CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user