or just take the line number from the string:use strict; use warnings; $_ =<<SQ; <exm>This is example 1 <exm>This is example 2 <exm>This is example 3 <exm>This is example 4 SQ s/<exm>/'<exm num="'.++$_.'">'/eg; print;
s/<exm>(?=.+?example\s+(\d+))/<exm num="$1">/g;
In reply to Re: Restarting counters in text
by sh1tn
in thread Restarting counters in text
by rsriram
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |