Regex for Video File Extension
Regex Pattern
\.(mp4|mov|avi|mkv|webm|flv|wmv|m4v)$Common video file extensions
Quick Answer
The regex pattern for video file extension is `\.(mp4|mov|avi|mkv|webm|flv|wmv|m4v)$`. Common video file extensions. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| movie.mp4 | ✓ Matches |
| clip.mov | ✓ Matches |
| video.webm | ✓ Matches |
| song.mp3 | ✗ No match |
| image.jpg | ✗ No match |
| video | ✗ No match |
Code Examples
javascript
const regex = /\.(mp4|mov|avi|mkv|webm|flv|wmv|m4v)$/; const isValid = regex.test(value);
python
import re
pattern = r'\.(mp4|mov|avi|mkv|webm|flv|wmv|m4v)$'
if re.match(pattern, value):
print("valid")ruby
pattern = /\.(mp4|mov|avi|mkv|webm|flv|wmv|m4v)$/ if value =~ pattern puts "valid" end
php
if (preg_match('/\.(mp4|mov|avi|mkv|webm|flv|wmv|m4v)$/', $value)) {
echo "valid";
}java
String pattern = "\\.(mp4|mov|avi|mkv|webm|flv|wmv|m4v)$"; boolean isValid = value.matches(pattern);
Frequently Asked Questions
Related Regex Patterns
File Extension
File extension at the end of a filename
Image File Extension
Common image file extensions
Absolute Unix Path
Absolute filesystem path starting with /
Email Address
Validates a standard email address format
Email (RFC 5322 Compliant)
RFC 5322 compliant email validation with label length limits
URL (HTTP/HTTPS)
Validates HTTP and HTTPS URLs