"be consistent" | |
PerlMonks |
Perl Regex Help!by Anonymous Monk |
on Mar 23, 2013 at 11:59 UTC ( [id://1025026]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: Dear PerlMonks, I have a simple question. kindly help me if possible.... I have some names. some have a country code in front of that name, but some don't. The country code is either 2 digit or 3 digit codes and is seperated with a hyphen. I wish to extract the country code using perl regex (remember some doesn't have the country codes). Below are some of the example names.
Pls note that some are not having country codes but having a hyphen. I Only want to extract if there is a country code. Basically if the digit count matches 2 or 3 before the first hyphen, I need to do the extract and leave the rest(if not like that). Pls can anyone suggest me a simple regex for this. I am planning to do the $name one at a time, so dont need to loop or something... just that basic regex which separate those county codes. Thank you Monks.
Back to
Seekers of Perl Wisdom
|
|