#!/usr/bin/perl -l # https://perlmonks.org/?node_id=1227618 use strict; use warnings; my $want = q{UK_Mobile_Vodafone_GBRVF}; my $dest = q{UK Mobile - Vodafone [GBRVF] [MSRN]}; print $dest; $dest =~ s/( )|- |\[|\].*/ '_' x !!$1 /ge; print $dest; print $want;
In reply to Re: Search and replace regex, but only retain a portion of the string
by tybalt89
in thread Search and replace regex, but only retain a portion of the string
by ghenry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |