Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Search and replace regex, but only retain a portion of the stringby ghenry (Vicar) |
on Dec 22, 2018 at 22:11 UTC ( [id://1227618]=perlquestion: print w/replies, xml ) | Need Help?? |
ghenry has asked for the wisdom of the Perl Monks concerning the following question: Dear monks, It's been a long time, but I know this is the right place to ask. So here goes. I'm looking for a pointer to the right doc section to read in https://perldoc.perl.org/perlre.html to help me with my test code below:
which gives me UK_Mobile_Vodafone_GBRVF_MSRN_ I'm trying to turn UK Mobile - Vodafone [GBRVF] [MSRN] into UK_Mobile_Vodafone_GBRVF_, but [MSRN] might not always be there. I want this done all in one substitution too. I think I even want to get to UK_Mobile_Vodafone_GBRVF. The software I'm doing this in can possibly process the same variable twice, with the second run being a second substitution, so I could make UK Mobile - Vodafone [GBRVF] [MSRN] become UK Mobile - Vodafone [GBRVF], then process it again to become UK_Mobile_Vodafone_GBRVF_ Many thanks,
Back to
Seekers of Perl Wisdom
|
|