How to use match group in Python to take a values and ignore comma mark I have a function working very well by getting the frames from the filename.
But it takes only the last number (frame) from the file name.

An example:

Filename:
1200,4500.avi

The code made to get the last number (frames), and it can import multiple avi files from specific folder.

Here's the code:

def insert_types(out, dir):
    for root, dirs, files in walk(dir):
        for f in files:
            match = search(r"(\d*)\.avi$", f)
            if match:
                startframe = match.group(1)
                out = InsertSign(out, join(root, f), int(startframe))
    return out

out = jpop.mkv
out = insert_types(out, r"D:\path\avi_folder")
return out


InsertSign() function have an option to put the start &amp; end frame of the file (if I'm doing it manually).

An example:

video = jpop.mkv
sign = 1200,4500.avi
startframe = 1200
endframe = 4500
final = InsertSign(video,sign, startframe,endframe)
return final


I tried many times and to find out how to change the insert_types function to take the first &amp; last number (1200, 4500) from the file name (1200,4500.avi) at the same time ignoring the comma mark (,) which is in the file name.

I tried to do it by myself but its beyond my means ^^"

Hope someone can help me with that

Regards.
Instead of

            match = search(r"(\d*)\.avi$", f)
            if match:
                startframe = match.group(1)
                out = InsertSign(out, join(root, f), int(startframe))


use

            match = search(r"(\d+),(\d+)\.avi$", f)
            if match:
                startframe = match.group(1)
                endframe = match.group(2)
                out = InsertSign(out, join(root, f), int(startframe), int(endframe))