File & Path

File Extension

Captures the file extension from a filename.

Try it in RegexPro

Pattern

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

Matches

  • .pdf

Input

archive.tar.gz

Matches

  • .gz

Input

no-extension

No match

Common use cases

  • File filters
  • MIME type detection
  • Upload validation