Is there a regular expression in Perl to find a file's extension? For example, if I have "test.exe
", how would I get the ".exe
"?
相关问题
- $ENV{$variable} in perl
- Is it possible to pass command-line arguments to @
- Redirecting STDOUT and STDERR to a file, except fo
- Change first key of multi-dimensional Hash in perl
- How do I get a filehandle from the command line?
相关文章
- Running a perl script on windows without extension
- Comparing speed of non-matching regexp
- Can NOT List directory including space using Perl
- Extracting columns from text file using Perl one-l
- Lazy (ungreedy) matching multiple groups using reg
- How do I tell DBD::mysql where mysql.sock is?
- What is a good way to deploy a Perl application?
- Speeding up Selenium Webdriver
Here it is a regex to match pattern n-level extension file (e.g. .tar.gz or .tar.bz2).
Example:
use
File::Basename
You could use File::Basename to extract an arbitrary file extension:
This would give you everything after the last dot (including the dot itself) until the end of the string.