Replace number sequentially with grep


/ Published in: Perl
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #caso 1
  2. #================
  3.  
  4.  
  5. #!/usr/bin/perl -w
  6. $ii = 0;
  7. while(<>) {
  8. my $increment = $_;
  9. $increment =~ s/(href=\"\#n|\">|id=\"n)\d/$1.$ii++/e;
  10. print $increment;
  11. }
  12.  
  13. #caso 2
  14. #================
  15.  
  16.  
  17.  
  18. #!/usr/bin/perl -w
  19. $ii = 0;
  20. while(<>) {
  21. my $increment = $_;
  22. $increment =~ s/(<a class=\"note\" epub:type=\"noteref\" href=\"\#n\d+\">)\d/$1.$ii++/e;
  23. print $increment;
  24. }
  25.  
  26. #caso 3
  27. #================
  28.  
  29.  
  30. #!/usr/bin/perl -w
  31. $ii = 0;
  32. while(<>) {
  33. my $increment = $_;
  34. $increment =~ s/( id=\"n)\d/$1.$ii++/e;
  35. print $increment;
  36. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.