Remove path from <img src=...>

General discussions about Advanced Find and Replace
Post Reply
Mr.Chaos
Posts: 2
Joined: Fri Mar 31, 2006 1:32 pm

Remove path from <img src=...>

Post by Mr.Chaos »

Hi,

I have several html files, that contain images (jpg and gif). I want to strip the paths, and keep only the filename, can that be done?

They all have different codes, from which I want to remove the red parts:

<img src="http://www.somedomain.com/blabla/file1.jpg">
<img src=http://www.somewhere.net/blabla/blabla2/file2.jpg>
<img src=http://www.myhomepage.com/folder/file3.gif height=100>
<img src="http://www.hello.com/file4.jpg" alt="blabla">

tags like <a href="http://www.google.nl>Google</a> should stay intact!


Thanks for the help!

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

Go to main menu - Action - Options - Batch Replace
check "Modifier G"
check "Modifier I"

Go to Batch replace tab, check on "Use regular expressions".
Put into the grid, search for:
<img src=.*/(.+\.\w+.*)>

Replace with:
<img src=$1>

That's all I verified it works perfectly.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

Mr.Chaos
Posts: 2
Joined: Fri Mar 31, 2006 1:32 pm

Post by Mr.Chaos »

That's great! Thank you!

Post Reply