File & Path
File Extension
Captures the file extension from a filename.
Try it in RegexProPattern
regexJavaScript
/\.([A-Za-z0-9]+)$/Raw source: \.([A-Za-z0-9]+)$
How it works
`\.` matches the literal dot. `([A-Za-z0-9]+)$` captures alphanumeric characters up to the end of the string.
Examples
Input
document.pdfMatches
.pdf
Input
archive.tar.gzMatches
.gz
Input
no-extensionNo match
—Common use cases
- File filters
- MIME type detection
- Upload validation