<p>Instead of</p>

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

<p>use</p>

<pre><code>            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))
</code></pre>

CC BY-SA 4.0
2020-05-21T09:16:41.847Z
You're welcome. Please upvote and/or accept my answer if it was useful for you.
MarianD
CC BY-SA 4.0
2020-05-21T00:39:59.270Z
2020-05-21T00:39:59.270Z
MarianD
<p>I have a function working very well by getting the frames from the filename.<br>
But it takes only the last number (frame) from the file name.</p>

<p>An example:</p>

<p>Filename:<br>
1200,<strong><em>4500</em></strong>.avi</p>

<p>The code made to get the last number (<strong><em>frames</em></strong>), and it can import multiple avi files from specific folder.</p>

<p>Here's the code:</p>

<pre><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
</code></pre>

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

<p>An example:</p>

<pre><code>video = jpop.mkv
sign = 1200,4500.avi
startframe = 1200
endframe = 4500
final = InsertSign(video,sign, startframe,endframe)
return final
</code></pre>

<p>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 (<code>1200,4500.avi</code>) at the same time ignoring the comma mark (<strong><code>,</code></strong>) which is in the file name.</p>

<p>I tried to do it by myself but its beyond my means ^^"</p>

<p>Hope someone can help me with that</p>

<p>Regards.</p>

<video><video-editor>
How to use match group in Python to take a values and ignore comma mark
AL-KOON
# How to use match group in Python to take a values and ignore comma mark

(Asked by: username_0 on 2020-05-20)

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 & 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 & 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.

**Tags:** video, video-editor


---

## 1 answers

### Answer by username_1 on 2020-05-21. Score: 0 | Accepted answer

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))

> **Comments:**
> **username_1**: You're welcome. Please upvote and/or accept my answer if it was useful for you.  

---

