0

Hi I have strings like:

** Dealing Flop ** [ As, 4s, 8h ]
** Dealing Turn ** [ 4h ]
** Dealing River ** [ 3s ]

I need know is it flop turn or river and what cards has been dealt. for now I have

new Regex(@"^\*\* Dealing (?<flop>F)|(?<turn>T)|(?<river>R)");

and what i need should be something like

new Regex(@"^\*\* Dealing (?<flop>F)|(?<turn>T)|(?<river>R)*[(?<cards>)]$");

but it does not work. Please help.Thank you.

3 Answers3

0

Surely this would be a lot more readable by using .Contains()?

enum Situation {
 Flop, 
 Turn,
 River
}

Situation GetSituation(string input){
 if(input.Contains("Flop"){ return Situation.Flop;}
 if(input.Contains("Turn"){ return Situation.Turn;}
 if(input.Contains("River"){ return Situation.River;}
 throw new ArgumentException("Invalid situation");
}

You can get the played hands like this:

var start = myString.IndexOf("[");
var end = myString.IndexOf("]");
var hands = myString.SubString(start, (end - start)).Split(",");
Jeroen Vannevel
  • 43,651
  • 22
  • 107
  • 170
0

If you want check if in the string there is Dealing Flop/River or Turn you can use this regex

(.*Dealing Flop| Dealing Turn| Dealing River.*)

And then you can extract from string all data that you need. But sincerely I prefer @JeroenVannevel method because it's more clear and simply to understand

Tinwor
  • 7,765
  • 6
  • 35
  • 56
0

You can use this pattern to know the situation and the cards:

\b(?<ftr>Flop|Turn|River) \*\* \[ (?<c1>[^], ]+)(?>, (?<c2>[^], ]+))?(?>, (?<c3>[^] ]+))? ]
Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125