Python (re)

Video File Extension in PY

Match common video file extensions: mp4, mov, avi, mkv, webm, m4v, flv, wmv, mpg, mpeg.

Try it in the PY tester →

Pattern

regexPY
\.(mp4|mov|avi|mkv|webm|m4v|flv|wmv|mpg|mpeg)$   (flags: i)

Python (re) code

pyPython
import re

pattern = re.compile(r"\.(mp4|mov|avi|mkv|webm|m4v|flv|wmv|mpg|mpeg)$", re.IGNORECASE)
input_text = "movie.mp4"
for m in pattern.finditer(input_text):
    print(m.group(0))

Stdlib `re` module — no third-party dependency. Works on Python 3.6+.

How the pattern works

\. matches the literal dot. The alternation covers the most common video container formats. The trailing $ anchors to end-of-string so we don't match `.mp4` mid-filename. The i flag makes matching case-insensitive (.MOV, .Mp4, etc.).

Examples

Input

movie.mp4

Matches

  • .mp4

Input

footage.MOV

Matches

  • .MOV

Input

song.mp3

No match

Same pattern, other engines

← Back to Video File Extension overview (all engines)