File & Pathflags: i
Video File Extension
Match common video file extensions: mp4, mov, avi, mkv, webm, m4v, flv, wmv, mpg, mpeg.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("\\.(mp4|mov|avi|mkv|webm|m4v|flv|wmv|mpg|mpeg)$", "i");
const input = "movie.mp4";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
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+.
Go (RE2) code
goGo
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`(?i)\.(mp4|mov|avi|mkv|webm|m4v|flv|wmv|mpg|mpeg)$`)
input := `movie.mp4`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
regexengine-agnostic
\.(mp4|mov|avi|mkv|webm|m4v|flv|wmv|mpg|mpeg)$ (flags: i)Raw source: \.(mp4|mov|avi|mkv|webm|m4v|flv|wmv|mpg|mpeg)$
How it 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.mp4Matches
.mp4
Input
footage.MOVMatches
.MOV
Input
song.mp3No match
—Common use cases
- •Upload validation for media platforms
- •Build pipeline asset routing
- •Storage bucket lifecycle rules
- •Transcoding job dispatch by source format
Related patterns
Image File Extension
File & PathMatch common image file extensions: jpg, jpeg, png, gif, webp, svg, avif, bmp, ico, tif, tiff.
File Extension
File & PathCaptures the file extension from a filename.
Windows File Path
File & PathMatches absolute Windows file paths (e.g., C:\Users\file.txt).
Unix File Path
File & PathMatches absolute Unix/Linux file paths.