Video File Extension in JS
Match common video file extensions: mp4, mov, avi, mkv, webm, m4v, flv, wmv, mpg, mpeg.
Try it in the JS tester →Pattern
regexJS
\.(mp4|mov|avi|mkv|webm|m4v|flv|wmv|mpg|mpeg)$ (flags: i)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).
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.mp4Matches
.mp4
Input
footage.MOVMatches
.MOV
Input
song.mp3No match
—