Regex: match at least N number of search terms but with patterns dependent on position
My question is similar to that in regex: Match at least two search terms, but with added complexity:
Given a set of M numerical strings of same length:
11001100
11101010
10010010
00101101
And given substring patterns of the type “11 at position 0” or “10 at position 6” (with the position being any multiple of 2), how can I search for strings matching at least N of these patterns?
For example: ^(11|d{2}10|d{6}10)
matches all strings. However if I add {3,} to the regex to match “11101010” only (because it satisfies three out of three of those OR cases), it fails. Does anyone know how I can structure a regex like this?
If it matters, the patterns can also cover the same substring position, so for example it could be (11|d{6}10|d{6}00), and this ideally would match both the first and second lines in my example if I wanted to only catch strings with two or more matches.
Read more here: Source link