diff --git a/zaaReloaded2/Importer/ZaaImporter/LaurisItem.cs b/zaaReloaded2/Importer/ZaaImporter/LaurisItem.cs index 7d76f9e..2996795 100755 --- a/zaaReloaded2/Importer/ZaaImporter/LaurisItem.cs +++ b/zaaReloaded2/Importer/ZaaImporter/LaurisItem.cs @@ -103,19 +103,15 @@ namespace zaaReloaded2.Importer.ZaaImporter // "HBs-Antigen: neg. ;" // "Erythrozyten (U): + [negativ]" Match match; - Regex numericalRegex = new Regex( - @"(?[^:]+):\s*(?[\d,.]+)\s*(?\[[^\]]+])?\s*(?[^;]+)?"); - Regex categoricalRegex = new Regex( - @"(?[^:]+):\s*(?[^[;]+)\s*(\[(?[^\]]+)])?"); - if (numericalRegex.IsMatch(LaurisText)) + if (_numericalRegex.IsMatch(LaurisText)) { - match = numericalRegex.Match(LaurisText); + match = _numericalRegex.Match(LaurisText); ParseLimits(match); Value = match.Groups["value"].Value.Trim().Replace(',', '.'); } else { - match = categoricalRegex.Match(LaurisText); + match = _categoricalRegex.Match(LaurisText); Normal = match.Groups["normal"].Value.Trim(); Value = match.Groups["value"].Value.Trim(); } @@ -136,8 +132,7 @@ namespace zaaReloaded2.Importer.ZaaImporter { if (match.Groups["limits"].Success) { - Regex limitRegex = new Regex(@"\[(?[-\d,.]+)?\s*(?\S+)\s*(?[-\d,.]+)?]"); - Match limitMatch = limitRegex.Match(match.Groups["limits"].Value); + 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 @@ -203,6 +198,11 @@ namespace zaaReloaded2.Importer.ZaaImporter #region Fields + static readonly Regex _numericalRegex = new Regex( + @"(?[^:]+):\s*(?[\d,.]+)\s*(?\[[^\]]+])?\s*(?[^;]+)?"); + static readonly Regex _categoricalRegex = new Regex( + @"(?[^:]+):\s*(?[^[;]+)\s*(\[(?[^\]]+)])?"); + static readonly Regex _limitRegex = new Regex(@"\[(?[-\d,.]+)?\s*(?\S+)\s*(?[-\d,.]+)?]"); static readonly Regex _materialRegex = new Regex(@"\((?(SU|PU))\)"); #endregion