This question is hard to answer as pattern and extracting might mean different things:
Is your pattern
including the spaces between the numbers, or just the list of number themselves? Is the pattern exactly 25 27 29
or n n+2 n+4
Does extract
mean finding the position? Removing it from the list?
Therefore, there are no algorithms or techniques as is it hard to understand what you are willing to do.
In a Python style and in a very general way (you can replace a
, b
and c
with integers and make the list longer), you can go for :
list = [25, 27, 29, 25, 27, 29, 25, 27, 29, 25, 27, 29, 25, 27, 28]
ptn = [a, b, c]
position = []
for i, nb in enumerate(list):
if i != len(list) - len(pattern);
if nb == ptn[i] and list[i+1] == ptn[i+1] and list[i+2] == ptn[i+2]:
position.append(i)