in reply to replace characters in link

Is there a way to do it ?

This is Perl, so TIMTOWTDI. In addition to haukex's approach with URI you could live a bit more dangerously and try any of these:

use strict; use warnings; use Test::More tests => 3; my $have = 'https://abc.abc:8080/abc?abcdef&abc=&egh?'; my $want = 'https://def.def/abc?abcdef&abc=&egh?'; my $try = $have; substr ($try, 8, 12, 'def.def'); is ($try, $want, 'substr'); ($try = $have) =~ s/\Qabc.abc:8080/def.def/; is ($try, $want, 'quotemeta regex'); my @bits = split ('/', $have, 4); $bits[2] = 'def.def'; $try = join '/', @bits; is ($try, $want, 'split/join');

There are plenty more too - this is just scratching the surface.

Replies are listed 'Best First'.
Re^2: replace characters in link
by Anonymous Monk on Dec 11, 2018 at 23:00 UTC
    What does the "is" keyword do in perl? I have been trying to find documentation on it, but I couldn't find anything.