Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Search and replace regex, but only retain a portion of the string

by tybalt89 (Monsignor)
on Dec 23, 2018 at 01:12 UTC ( [id://1227622]=note: print w/replies, xml ) Need Help??


in reply to Search and replace regex, but only retain a portion of the string

#!/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;
  • Comment on Re: Search and replace regex, but only retain a portion of the string
  • Download Code

Replies are listed 'Best First'.
Re^2: Search and replace regex, but only retain a portion of the string
by ghenry (Vicar) on Dec 23, 2018 at 13:43 UTC

    Very nice. Will have a play. Thank you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1227622]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-23 10:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found