$string1 = "<>randomtextABCD<>blablabla<-<->>-bla"
1 2 3
my $string1 = "<>randomtext<>blablabla<-<->>-bla"; my $string2 = "ABCD"; $string1 =~ s|(<>[^<]+)|$1${string2}|; # Ersetze in $string1 das Suchmuster durch das gefundene, also $1, und string2
$string1 =~ s|(<VT>[^<]+)|$1${string2}|;
$string1 =~ s/(<VT>)(.+)/$1${string2}$2/i;
1
2
3
4
5
6
7
# GwenDragon
$ perl -E '$s = "<VT>BLA</VT>"; $s =~ s|(<VT>[^<]+)|${1}string2|; say $s'
<VT>BLAstring2</VT>
# MarkusH
$ perl -E '$s = "<VT>BLA</VT>"; $s =~ s/(<VT>)(.+)/${1}string2${2}/i; say $s'
<VT>string2BLA</VT>