File Extension
beginnerExtracts file extensions from filenames.
fileextensionparsingtype
Pattern
/\.(\w{1,10})$/gmTry It
0 of 7 strings matched
Explanation
Matches a dot followed by 1-10 word characters at the end of a line. Captures the extension without the dot in group 1.
Test Strings
Matching
- file.txt
- image.png
- archive.tar.gz
- script.min.js
Non-matching
- no-extension
- README
- file.
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /\.(\w{1,10})$/gm;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);Common Variations
Specific types
\.(?:jpg|jpeg|png|gif|svg|webp)$Matches common image file extensions only