in reply to Search and replace regex, but only retain a portion of the string
$ perl my $s="UK Mobile - Vodafone [GBRVF] [MSRN]"; $s=~tr/a-zA-Z/_/cs; print "$s\n"; ^D UK_Mobile_Vodafone_GBRVF_MSRN_
Still needs the second pass to get rid of MSRN_, but clean and straightforward otherwise.
Edit: I see someone already updated another comment node to suggest this, apologies for the dupe.
|
---|