diff --git a/src/class.Validate.php b/src/class.Validate.php index d83ec63..58a1715 100644 --- a/src/class.Validate.php +++ b/src/class.Validate.php @@ -135,20 +135,20 @@ class Validate "ES" => 24, "SE" => 24, "CH" => 21, "TN" => 24, "TR" => 26, "AE" => 23, "GB" => 22, "VG" => 24 ]; - $iban = mb_ereg_replace("/(\s|\-)/", "", $iban); // sanitize for validation (remove spaces) - $country = mb_strtoupper(mb_substr($iban, 0, 2)); + $iban = preg_replace("/(\s|\-)/", "", $iban); // sanitize for validation (remove spaces) + $country = strtoupper(substr($iban, 0, 2)); // we know the country the IBAN belongs to? if(isset($country_length[$country])) { // The IBAN matches in length and basic structure? $matches = null; - if(mb_ereg_match('/^([A-Za-z]{2})(\d{2})([A-Za-z0-9]{' . ($country_length[$country]-4) . '})$/', $iban, $matches)) { + if(preg_match('/^([A-Za-z]{2})(\d{2})([A-Za-z0-9]{' . ($country_length[$country]-4) . '})$/', $iban, $matches)) { $checkNum = $matches[1]; $bban = strtoupper($matches[2]); // Replace letters with digits (a or A => 11, b or B => 12,..) - $checkString = mb_ereg_replace_callback('/[A-Z]/', function ($matches) { + $checkString = preg_replace_callback('/[A-Z]/', function ($matches) { return base_convert($matches[0], 36, 10); }, $bban . $country . '00'); @@ -188,7 +188,7 @@ class Validate $swift = trim($swift); // sanitize swift/bic if($iban !== null) { - $iban = mb_ereg_replace("/(\s|\-)/", "", $iban); // sanitize iban + $iban = preg_replace("/(\s|\-)/", "", $iban); // sanitize iban $api_result = file_get_contents("https://api.swiftrefdata.com/v1/ibans/$iban/bic.xml"); $api_result_array = json_decode(json_encode((array) simplexml_load_string($api_result)),1); @@ -199,7 +199,7 @@ class Validate } - return mb_ereg_match("^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$", $swift); + return preg_match("^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$", $swift); } } \ No newline at end of file