0

Ive got a regex that is meant to find all multilined comments and docstrings, so far it is currently only returning group 1 from the regex, what I want is the full match and corresponding line number, what would i have to change to find get these results?

code -

match = r'''(['"])\1\1[\d\D]*?\1{3}'''

textfile = open(file, 'r')
filetext = textfile.read()
textfile.close()
matches = re.findall(match, filetext)
print matches

example file on which I would be running this code on -

a = '\ttesting this file!'
b = "abc"
print a

def trigger():
    a = b'\r\n'
    b = "\t"


"""
dasdas
adasdsa
"""
class A:
    """
    dsadasd
    dsadas
    """
    def new():
        """
        dsadas
        :return:
        """

What the function returns -

['"', '"', '"']
new_ting
  • 49
  • 1
  • 5

0 Answers0