regex problem with re and fnmatch

Fabian Braennstroem f.braennstroem at
Tue Nov 20 22:05:58 CET 2007


I would like to use re to search for lines in a files with
the word "", where x is any number.
E.g. the structure would look like this:

I tried to use these kind of matchings:
#        org_files='.*README\]]'
        if re.match(org_files,line):

Unfortunately, it matches all entries with "", but
not the wanted number!?

After some splitting and replacing I am able to check, if
the above file exists. If it does not, I start to search for
it using the 'walk' procedure:

                for root, dirs, files in
                    for name in dirs:
                        dirs=os.path.join(root, name) + '/'
                    for name in files:
                         files=os.path.join(root, name)
                    if fnmatch.fnmatch(str(files), "README*"):
                        print "File Found"
                        print str(files)

As soon as it finds the file, it should stop the searching
process; but there is the same matching problem like above.
Does anyone have any suggestions about the regex problem?

More information about the Python-list mailing list