We need to find the regex pattern 10+1 in a given string. For this, we can use the re module available in python. This package has a method called find all that accepts the regex and the string we want to search in. It gives us all the occurrences of the pattern in that string. For example,
For the input string −
10000001 hello world 10011 test100000001test.
We should get the output −
10000001 1001 100000001
We can implement it using the re package as follows −
import re occ = re.findall("10+1", "10000001 hello world 10011 test100000001test.") for i in occ: print(i)
This will give the output −
10000001 1001 100000001