Question Regex pattern help

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
 
It's good that you corrected your mistake and posted to the correct forum but, in future, if you post to the wrong forum, please notify the mods so we can move it, rather than creating a duplicate. You can use the Report link under your post.
 

Latest posts

Back
Top