Regex Match Count

servox

Member
Joined
Jun 30, 2022
Messages
16
Programming Experience
Beginner
Hi All

I have bingo tickets data stored as a string and I'm needing your help to get a count of numbers need for a pattern to match


this is the string of the bingo ticket, its a 5x5 ticket store on a single line
06 22 31 46 64 03 23 40 51 74 01 25 36 55 75 08 17 43 56 69 11 21 41 60 70

so when the called number is on the ticket it changes the called number to 00
00 22 31 46 00 03 00 40 00 74 01 25 00 55 75 08 00 43 00 69 00 21 41 60 00

I can detect a winner by
Dim Winner As Boolean = StrTicketData Like "00 ?? ?? ?? 00 ?? 00 ?? 00 ?? ?? ?? ?? ?? ?? ?? 00 ?? 00 ?? 00 ?? ?? ?? 00"

If Winner = True Then
MessageBox.Show("Winner")
End If


but what I'm struggling with is getting the amount of numbers needed left for the pattern to be correct, so if only 2 number are marked as 00 like below
00 22 31 46 64 03 23 40 51 74 01 25 36 55 75 08 17 43 56 69 11 21 41 60 00

I need the count to show how many have been matched from the strPattern


this is what I've tried, but it doesn't work

'--- Letter X
Dim strPattern As String = "00 ?? ?? ?? 00 ?? 00 ?? 00 ?? ?? ?? ?? ?? ?? ?? 00 ?? 00 ?? 00 ?? ?? ?? 00"


Dim LetterX As Integer = 0
LetterX = Regex.Matches(StrTicketData ,strPattern RegexOptions.Singleline).Count


the pattern is like this on the ticket, its an X pattern and the center number is always free (e.g meaning its always marked as called)
00 ?? ?? ?? 00
?? 00 ?? 00 ??
?? ?? ?? ?? ??
?? 00 ?? 00 ??
00 ?? ?? ?? 00

I have properly gone about this all wrong as I'm still learning

hopefully someone will be able to help or guide me in the right direction

thanks

servox
 
Back
Top