in reply to Re^5: regex not matching how I want it to :(
in thread regex not matching how I want it to :(
Don't do multiple passes of the "while". In fact, don't do a "while" at all :)
#!/usr/bin/perl -l # https://perlmonks.org/?node_id=1224264 use strict; use warnings; my $line = '<p><a href="test1.htm"> test1</a><br> <a href="test2.htm"> + test2</a><br> <a href="test3.htm">test3</a><br> <a href="test4.htm"> + test4</a><br>'; my @replacements = 'xxx0001' .. 'xxx0100'; $line =~ s/<a href=\"\K.*?(?=\.htm\">)/ shift @replacements /gie; print $line;
|
|---|