Make regexes in LaurisItem static and readonly.
In order to speed parsing up a little bit.
This commit is contained in:
parent
66ad3886da
commit
6e969dacd9
@ -103,19 +103,15 @@ namespace zaaReloaded2.Importer.ZaaImporter
|
||||
// "HBs-Antigen: neg. ;"
|
||||
// "Erythrozyten (U): + [negativ]"
|
||||
Match match;
|
||||
Regex numericalRegex = new Regex(
|
||||
@"(?<name>[^:]+):\s*(?<value>[\d,.]+)\s*(?<limits>\[[^\]]+])?\s*(?<unit>[^;]+)?");
|
||||
Regex categoricalRegex = new Regex(
|
||||
@"(?<name>[^:]+):\s*(?<value>[^[;]+)\s*(\[(?<normal>[^\]]+)])?");
|
||||
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(@"\[(?<limit1>[-\d,.]+)?\s*(?<operator>\S+)\s*(?<limit2>[-\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(
|
||||
@"(?<name>[^:]+):\s*(?<value>[\d,.]+)\s*(?<limits>\[[^\]]+])?\s*(?<unit>[^;]+)?");
|
||||
static readonly Regex _categoricalRegex = new Regex(
|
||||
@"(?<name>[^:]+):\s*(?<value>[^[;]+)\s*(\[(?<normal>[^\]]+)])?");
|
||||
static readonly Regex _limitRegex = new Regex(@"\[(?<limit1>[-\d,.]+)?\s*(?<operator>\S+)\s*(?<limit2>[-\d,.]+)?]");
|
||||
static readonly Regex _materialRegex = new Regex(@"\((?<material>(SU|PU))\)");
|
||||
|
||||
#endregion
|
||||
|
Loading…
Reference in New Issue
Block a user