Index: sites/all/modules/contrib/phone/phone.nl.inc =================================================================== --- sites/all/modules/contrib/phone/phone.nl.inc (revision ) +++ sites/all/modules/contrib/phone/phone.nl.inc (revision ) @@ -6,6 +6,15 @@ * CCK Field for Dutch phone numbers. */ +define("PHONE_NL_REGEX", '/ + ((?:\+31[ ]?|[0]{1})[6]{1}[-\s]*[1-9]{1}[\s]*([0-9]{1}[\s]*){7}) # Mobile phonenumber + | + ((?:\+31[ ]?|[0]{1}){1}[1-9]{1}[0-9]{2}[-\s]*[1-9]{1}[\s]*([0-9]{1}[\s]*){5}) # Phonenumber with 4 digit area code + | + ((?:\+31[ ]?|[0]{1}){1}[1-9]{1}[0-9]{1}[-\s]*[1-9]{1}[\s]*([0-9]{1}[\s]*){6}) # Phonenumber with 3 digit area code + /x' +); + function phone_nl_metadata() { // These strings are translated using t() on output. return array( @@ -40,17 +49,8 @@ 123 456 7890 */ - // define regular expression - $regex = '/ - ([0]{1}[6]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){7}) # Mobile phonenumber - | - ([0]{1}[1-9]{1}[0-9]{2}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){5}) # Phonenumber with 4 digit area code - | - ([0]{1}[1-9]{1}[0-9]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){6}) # Phonenumber with 3 digit area code - /x'; - // return true if valid, false otherwise - return (bool) preg_match($regex, $phonenumber); + return (bool) preg_match(PHONE_NL_REGEX, $phonenumber); } /** @@ -63,17 +63,9 @@ $areacode = $localnumber = ''; // Mobile number - if (preg_match('/([0]{1}[6]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){7})/', $phonenumber)) { - preg_match('/([0]{1}[6]{1})[-\s]+([1-9]{1}[\s]*([0-9]{1}[\s]*){7})/', $phonenumber, $matches); + if (preg_match(PHONE_NL_REGEX, $phonenumber)) { + preg_match(PHONE_NL_REGEX, $phonenumber, $matches); - } + } - // Phonenumber with 4 digit area code - if (preg_match('/([0]{1}[1-9]{1}[0-9]{2}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){5})/', $phonenumber)) { - preg_match('/([0]{1}[1-9]{1}[0-9]{2})[-\s]+([1-9]{1}[\s]*([0-9]{1}[\s]*){5})/', $phonenumber, $matches); - } - // Phonenumber with 3 digit area code - if (preg_match('/([0]{1}[1-9]{1}[0-9]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){6})/', $phonenumber)) { - preg_match('/([0]{1}[1-9]{1}[0-9]{1})[-\s]+([1-9]{1}[\s]*([0-9]{1}[\s]*){6})/', $phonenumber, $matches); - } $areacode = $matches[1]; $localnumber = preg_replace('/ /', '', $matches[2]);