Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have a little question. I have a big html file and want to replace lots of things inside a lot of times. The only problem i cant solve is a replace with a variable.


<image src="start_files\0002.jpg" style="width:216pt; height:162">

should be transformed in

<a href="start_files\0002.jpg" target="_blank"><image src="start_files\0002.jpg" style="width:216pt; height:162"></a>

do you have an idea how to do it?

I have a windows system with Notepad2 and Notepad++ and i could install a new tool if needed. (like Windows SED). The best solution would be a batch solution where I can add other transformations.

Hope you have got good ideas!

share|improve this question

Notepad++ has regular expression search & replace support. You just need to craft a regex to meet your conditions.

share|improve this answer
But can i reference parts of the search in the replace? – Fake4d Mar 23 '12 at 12:47

You could use a perl script (to use with grep e.g.):

$src='<image src="start_files\\0002.jpg" style="width:216pt; height:162">';
$xp3='( )';
$xp7='( )';
if ($src =~ m/$xp/is)
        $outi="<a href="."$6"." target=\"_blank\"> "."$1$2$3$4$5$6$7$8$9$10$11 \n";
    print $outi;    
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.