In this paper we propose a new algorithm called MEPda (Motif Extraction algorithm based on Push-down automata) to solve the problem of finding patterns containing loops. These loop-patterns or loop-motifs are very known and used in many domains, especially in mathematics and bioinformatics. MEPda meant to find these kinds of patterns by using pushdown automata as a mechanism of matching process alongside with a counter to verify the acceptance length of loop in an optimistic way of looking. The results obtained from MEPda have shown high accuracy and much reduced runtime for finding patterns containing loops compared to using a push-down automata based algorithm without implementing a counter, a regular expression based algorithm, an Aho-Corasick algorithm, a KMP algorithm, and MoTeX algorithm.