Skip to content
Advertisement

how to define selection condition in regex in python

I am having a string in which some binary numbers are mentioned. I want to count number of occurrence of given pattern, but I want set my pattern above 7 digits of character, so the result should show only more than 7 characters. it means how I can set my pattern selection, so it should count only 7 digits and above (pattern = r”(0+1+0+1+0+1+)” {<7} ). please note: it should select 7 digits and above, not just fixed 7 digits.

JavaScript

result should be show only more than 7 character it no supposed to show (‘010101’, 2)

Advertisement

Answer

The simplest solution is to filter the list of regex matches.

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement