Search code examples
pythonregexfuzzypypi-regex

Fuzzy regex matching with python returns empty list


I have made a clumsy first attempt at fuzzy pattern matching using the re module in python 2.7.

Unfortunately every attempt I make returns an empty list. I simply don't understand the syntax required. I was wondering if someone might tell me why the following code:

import re
m = re.findall('(ATCT){e<=1}', 'ATCGATCGGCATGCAGTGCAGAAGTGACGAT')
print m

returns an empty list?


Solution

  • Since you intended to use the PyPi regex module, you need to use

    >>> import regex
    >>> m = regex.findall('(ATCT){e<=1}', 'ATCGATCGGCATGCAGTGCAGAAGTGACGAT')
    >>> print(m)
    ['ATCG', 'ATCG']