in reply to Re^3: Newbie regular expressions question
in thread Newbie regular expressions question

Further to davido's post:
bayareamonk: You say you have Perl 5.10 available (which provides \K), so here's a small simplification:

c:\@Work\Perl\monks>perl -wMstrict -le "use Regexp::Common 'net'; ;; my $input = qq{<yoda yoda> <ip-compute-10.10.10.1-internal> <yadda ya +dda> \n} . qq{<more stuff>} ; print qq{[[$input]] \n}; ;; my $want = qq{<yoda yoda> <ip-compute-10.10.25.18-internal> <yadda ya +dda> \n} . qq{<more stuff>} ; ;; my $replacement_ip = '10.10.25.18'; ;; $input =~ s{ <ip-compute- \K $RE{net}{IPv4} (?= -internal>) } {$replacement_ip}xmsg; ;; print $input eq $want ? 'Success:' : 'Failure:'; print qq{[[$input]]}; " [[<yoda yoda> <ip-compute-10.10.10.1-internal> <yadda yadda> <more stuff>]] Success: [[<yoda yoda> <ip-compute-10.10.25.18-internal> <yadda yadda> <more stuff>]]