Hi, You could use this
even addressing the excellent point raised by tobyinkprint $1, $/ if ( $location =~ m{(?<=:)(?:.-)?(.+?)$} );
OUTPUT#!/usr/bin/perl use warnings; use strict; while ( defined( my $location = <DATA> ) ) { chomp $location; print $1, $/ if ( $location =~ m{(?<=:)(?:.-)?(.+?)$} ); } __DATA__ $names = Location:G-Canada $names = Location:Germany $names = Location:p-Australia $names = Location:e-Britain $names = Location:USA $names = Location:c-India $names = Location:Netherlands $names = Location:r-China $names = Location:North Korea $names = Location:Vatican City $names = Location:South Sudan $names = Location:Timor Leste $names = Location:Papua New Guinea
Canada Germany Australia Britain USA India Netherlands China North Korea Vatican City South Sudan Timor Leste Papua New Guinea
In reply to Re: Is there a better way to get the Country names with help of Regax
by 2teez
in thread Is there a better way to get the Country names with help of Regax
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |