Suppose I have a string like this 123456789
. Is there any way to find the every possible existing pattern from the given string like this
1234
, 2345
, 3456
,4567
, 5678
, 6789
using regex
I did this but couldn't figure out the solution:
import re
regex = r"[1-9]{4}"
test_string = "123456789"
print(re.findall(regex, test_str))
this outputs:
['1234', '5678']
Any help will mean a lot to me, Thanks