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 match = input.match(re);
console.log(match ? match[0] : null);

Uses `String.prototype.match`, which returns the first match or null.

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

Matches

  • .mp4

Input

footage.MOV

Matches

  • .MOV

Input

song.mp3

No 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