use strict;
my $str = 'd: url(../images/printer.gif) top left no-repeat; {
.preview .mw-wiki-logo {
background-image: url(/static/images/project-logos/enwiki-1.5x.png); background-size: 135px auto background-image: url(/static/images/project-logos/enwiki-2x.png);
.preview li.mw-changeslist-line-watched, .preview li.mw-history-line-updated {
list-style-image: url(//upload.wikimedia.org/wikipedia/commons/1/19/ChangedBulletVector.svg);
list-style-image: url(//upload.wikimedia.org/wikipedia/commons/c/c2/ChangedBulletVector.png) \\9
}
}
}
@media (-webkit-min-device-pixel-ratio: 2),(min--moz-device-pixel-ratio: 2),(min-resolution: 2dppx),(min-resolution: 192dpi) {
.preview .mw-wiki-logo {
background-image: url(/static/images/project-logos/enwiki-2x.png);
background-size: 135px auto
}
}';
my $regex = qr/url\([\.]{2}\/(\w+(([\/]\w+)*(-\w+|\.\w+))*)/p;
my $subst = 'url(//en.wikipedia.org/${1})';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html