in reply to Find and replace using regex

Hi rsriram, Try this,

use strict; use warnings; my $data = do{local $/; <DATA>}; my $i = 1; while ($data =~ s/(<FN$i>(?:(?:(?!<\/FN$i>).)*)<\/FN$i>)\n*//gsi){ my $foot = $1; $data=~ s/<FN${i}ref>/$foot/gi; $i++; } print $data; __DATA__ This is my text<FN1ref>. This is my text This is my text. This is my text<FN2ref>. This is my text This is my text. This is my text<FN3ref>, this is my text This is my text. This is my text<FN4ref>, this is my text This is my text. This is my text<FN5ref>, this is my text This is my text. <FN1>Footnote1</FN1> <FN2>Footnote2</FN2> <FN3>Footnote3</FN3> <FN4>Footnote4</FN4> <FN5>Footnote5</FN5> Output: ------- This is my text<FN1>Footnote1</FN1>. This is my text This is my text. This is my text<FN2>Footnote2</FN2>. This is my text This is my text. This is my text<FN3>Footnote3</FN3>, this is my text This is my text. This is my text<FN4>Footnote4</FN4>, this is my text This is my text. This is my text<FN5>Footnote5</FN5>, this is my text This is my text.

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';