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
  • 112,593
  • 23
  • 157
  • 280
Makogan
  • 6,665
  • 6
  • 40
  • 87

0 Answers0