0

I am trying to parse the output of a git command with a python script. To that effect, let's say we want to find all the modified and added files in git status, then we would do something like this:

import glob
import os
import re
import git

def main():
    g = git.cmd.Git('./')

    layout_pattern = '(modified:|new file:).*'
    matches = re.findall(layout_pattern, g.status())
    print(matches)

if __name__ == "__main__":
    main()

However, the output from python is truncated:

['modified:', 'new file:', 'modified:', 'modified:']

There is an explicit .* expression in the pattern, it should match all the way to the end of the line, why isn't it?

martineau
  • 119,623
  • 25
  • 170
  • 301
Makogan
  • 8,208
  • 7
  • 44
  • 112

0 Answers0