Reputation: 3680
I have come up with a regex to find me all the image within a project.
(\/|\\)(.*)\.(gif|png|jpg|jpeg)
What I am trying to do now, is find the extension (gif|jpg|etc...) and then capture the word preceeding that match (ie the filename).
I'm totally stuck on how to structure a lookbehind capture group(??)
What I am doing is looking through a large web project finding all the images that have been actually used in code, and then I'm going to clean up the image directory for ones that are no longer referenced.
Upvotes: 1
Views: 125
Reputation: 91518
With Npp, you could search:
([^\/\\]+)(?=\.(gif|png|jpg|jpeg))
or
([^\/\\]+)(?=\.(?:gif|png|jpe?g))
to match the filename.
According to comment, you can do the find/replace with:
^.*?([^\/\\]+\.(?:gif|png|jpe?g)).*?$
$1
This will remove everything in a line except the filename+extension.
Upvotes: 2