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.
$name = "UK-Storee Leaader"; $name = "US-Inventory Specialiist"; $name = "Verifiication Engiineer - Techniical"; $name = "CHN-Speciialist"; $name = "Software Engiineer - Telecom"; $name = "ESP-Busiiness Manager"; $name = "Software Engiineer - Productiiviity"; $name = "FRA-Busiiness Speciialist"; $name = "CAN-Busiiness Speciialist"; $name = "CHE-Inventory Specialiist"; $name = "HK-Iinventory Speciialiist"; $name = "ITA-Speciialist"; $name = "NLD-Busiiness Specialiist";
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.
In reply to Perl Regex Help! by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |