2021 © RegexOne
If you use Linux or the command line frequently, are often dealing with lists of files. Most files have a filename component as well as an extension, but in Linux, it is also common to have hidden files that have no filename.
In this simple example, extract the filenames and extension types of only image files (not including temporary files for images currently being edited). Image files are defined as .jpg,.png, and .gif.
We are only looking for image files ending with the 'jpg', 'png' and 'gif' file extensions, so we can capture all such filenames using the expression (\w+)\.(jpg|png|gif)$.