Last active
September 27, 2022 10:32
-
-
Save refo/eb0f8f84d2d84822a1da21c2ac0331f3 to your computer and use it in GitHub Desktop.
Türkiye telefon numarası parse et.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var input = " + 9 0 asdas (532) 123 - 45 6 7 "; | |
var telefon = input.replace(/(^\D*9?\D*0|\D+)/ig, ''); | |
console.log(telefon); | |
// Şunu yazdırır: | |
// 5321234567 | |
// | |
// Çıktı 10 karakter ise, numara doğru kabul edilebilir. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$input = " + 9 0 asdas (532) 123 - 45 6 7 "; | |
echo preg_replace("/(^\D*9?\D*0|\D+)/i", "", $input); | |
// Şunu yazdırır: | |
// 5321234567 | |
// | |
// Çıktı 10 karakter ise, numara doğru kabul edilebilir. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment