summaryrefslogtreecommitdiff
path: root/PBNBoard.cs
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-05-23 22:19:05 +0200
committeremkael <emkael@tlen.pl>2016-05-23 22:19:05 +0200
commitde13333bdef5458200e83f326a0a9e7f26de1681 (patch)
tree606b290a22958b576c43abc6b76a43aaaeda69a3 /PBNBoard.cs
parentbdb949a301df0ccdc5bebd4fa3ad0939a4e423b8 (diff)
* PBN parsing regexes moved to static members
Diffstat (limited to 'PBNBoard.cs')
-rw-r--r--PBNBoard.cs13
1 files changed, 7 insertions, 6 deletions
diff --git a/PBNBoard.cs b/PBNBoard.cs
index e04fb37..72f87a4 100644
--- a/PBNBoard.cs
+++ b/PBNBoard.cs
@@ -39,15 +39,18 @@ namespace BCDD
private bool? hasOptimumResultTable = null;
private bool? hasAbility = null;
+ private static Regex linePattern = new Regex(@"\[(.*) ""(.*)""\]");
+ private static Regex abilityPattern = new Regex(@"\b([NESW]):([0-9A-D]{5})\b");
+ private static Regex optimumResultTablePattern = new Regex(@"^([NESW])\s+([CDHSN])T?\s+(\d+)$");
+
public PBNBoard(List<string> lines)
{
this.Fields = new List<PBNField>();
- Regex linePattern = new Regex(@"\[(.*) ""(.*)""\]");
foreach (String line in lines)
{
PBNField field = new PBNField();
field.RawField = line;
- Match lineParse = linePattern.Match(line);
+ Match lineParse = PBNBoard.linePattern.Match(line);
if (lineParse.Success)
{
field.Key = lineParse.Groups[1].Value;
@@ -119,8 +122,7 @@ namespace BCDD
public MatchCollection ValidateAbility(String ability)
{
- Regex abilityMatch = new Regex(@"\b([NESW]):([0-9A-D]{5})\b");
- MatchCollection matches = abilityMatch.Matches(ability);
+ MatchCollection matches = PBNBoard.abilityPattern.Matches(ability);
if (matches.Count != 4)
{
this.hasAbility = false;
@@ -210,12 +212,11 @@ namespace BCDD
public List<Match> ValidateOptimumResultTable(List<String> table)
{
- Regex linePattern = new Regex(@"^([NESW])\s+([CDHSN])T?\s+(\d+)$");
List<Match> matches = new List<Match>();
List<String> duplicates = new List<String>();
foreach (String line in table)
{
- Match match = linePattern.Match(line);
+ Match match = PBNBoard.optimumResultTablePattern.Match(line);
if (!match.Success)
{
this.hasOptimumResultTable = false;