Question Regex Pattern Help

Status
Not open for further replies.

servox

Member
Joined
Jun 30, 2022
Messages
15
Programming Experience
Beginner
Hi all

I’m trying to search a string using Regex and have trouble finding a pattern

I have a string which is spilt into 3 groups of 5 numbers

01 00 01 01 01 00 00 00 00 00 01 00 01 00 01


I want to count how many 00 their is in each group and hopefully get the position in the string

The goal is to
Detect 5 in a group
Detect 10 over 2 groups
Detect 15 over 3 groups

Currently I have split the string into separate strings and check each string

01 01 01 01 01
00 00 00 00 00
01 00 01 00 01

Result1 = Regex.matches(line(0), “00”).count

Result2 = Regex.matches(line(1), “00”).count

Result3 = Regex.matches(line(2), “00”).count

If result1 = 5 or result2 = 5 or result3 = 5
Some code
End if

If result1 = 4 or result2 = 4 or result3 = 4
Some code
End if

Down to result1 = 1

But this is very slow then checking 100’s of strings

So hopefully someone could help my find a solution to a single string method

If changing the string would help to
01,01,00,01,00
Or
01-01-00-01-00
Or
01,00,01,01,01-00,00,00,00,00-01,00,01,00,01

I can

Thanks in advance
 
Status
Not open for further replies.
Back
Top