Data & Formatting · In-Browser Regular Expression Lab
Image Extension Regex — Match PNG, JPG, WebP, SVG & AVIF
Matches filenames ending with common web image formats (png, jpg, jpeg, webp, svg, avif, gif).
Flags:
//i
Match Found
Load Sample:
Match Inspection & Details1 match
Match #1:.png
Test Samples Verification Matrix
Expected Valid Samples (Should Match)
avatar.png Pass
hero-banner.webp Pass
icon.SVG Pass
photo.JPEG Pass
Expected Invalid Samples (Must Reject)
document.pdf Rejected (Pass)
bundle.js Rejected (Pass)
style.css Rejected (Pass)
image.png.txt Rejected (Pass)
Code Implementation Generator
// JavaScript / TypeScript (ES6+)
const pattern = /\.(jpe?g|png|gif|webp|svg|avif|ico|bmp)$/i;
const text = "avatar.png";
const isMatch = pattern.test(text);
console.log("Is Match:", isMatch);
if (isMatch) {
const matches = text.match(pattern);
console.log("Matches:", matches);
}Regular Expression Token Breakdown
Case-insensitive check for common image file extensions at string termination. Each component of the regular expression serves a distinct syntactical purpose as mapped below:
| Token Pattern | Name / Component | Function & Rule |
|---|---|---|
| \. | Period | Literal dot before extension. |
| (jpe?g|png...) | Extension group | Allowed image format extensions. |
| $ | End of String | Ensures extension is at the end of filename. |
Frequently Asked Questions
How to match image URLs with query params?
Related Regular Expressions
Browse All 40 PatternsCode & Markup
HTML Tags Matcher & Stripper
Matches HTML markup tags for sanitization, stripping, or token extraction.
/<\/?[a-zA-Z][a-zA-Z0-9]*(?:\s+[^>]*?)?\/?>/gTest regex
Data & Formatting
URL Slug Matcher
Matches lowercase alphanumeric strings separated by single hyphens, ideal for SEO permalinks.
/^[a-z0-9]+(?:-[a-z0-9]+)*$/Test regex
Network & Web
HTTP & HTTPS URL Validation
Matches fully qualified URLs starting with http:// or https://, including subdomains, paths, ports, and query parameters.
/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}(?:\.[a-zA-Z0-9()]{1,6})?(?::[0-9]{1,5})?\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/iTest regex