How to remove country code , When Pick Phone Number from contacts
use this function hope it will help you out:
public String phoeNumberWithOutCountryCode(String phoneNumberWithCountryCode) {
Pattern complie = Pattern.compile(" ");
String[] phonenUmber = complie.split(phoneNumberWithCountryCode);
Log.e("number is", phonenUmber[1]);
return phonenUmber[1];
}
Remove country code from phone number?
Use the following regex substitution:
if your format is : +12223334444
$country_code = '+1';
$phone_no = '+12223334444';
echo preg_replace('/^\+?1|\|1|\D/', '', ($phone_no));
Output will : 2223334444
if your format is : 12223334444
$country_code = '1';
$phone_no = '2223334444';
echo preg_replace('/^\+?1|\|1|\D/', '', ($phone_no));
Output will : 2223334444
MySQL: SQL to remove country code from phone number
One way of doing this would be to do a regex replacement:
UPDATE customers
SET phone = REGEXP_REPLACE(phone, '^\\+[0-9]+ ', '');
Demo
If you're using a version of MySQL earlier than 8+, then we can use the base string functions as a workaround:
UPDATE customers
SET phone = SUBSTR(phone, INSTR(phone, ' ') + 1)
WHERE phone LIKE '+%';
Demo
How to remove the country code from the mobile number?
You must know the country to achieve this. Please find my answer, it is helpful to you if you have the countries list. And let me know if you have any issues.
public string RemoveCountryCode()
{
string phonenumber = "+91123123123";
List<string> countries_list = new List<string>();
countries_list.Add("+1");
countries_list.Add("+91");
foreach(var country in countries_list)
{
phonenumber = phonenumber.Replace(country, "");
}
return phonenumber;
}
Related Topics
Warning: Mysqli_Connect(): (Hy000/1049): Unknown Database in MAC Terminal Only
How to Send Data Using Redirect With Laravel
Convert Doc/Docx Files to Pdf Using PHP
How to Delete Completed Orders in Woocommerce Using a My SQL Query
How to Add Class to Link in Wp_Nav_Menu
Should We Ever Check For MySQLi_Connect() Errors Manually
MySQL Great Circle Distance (Haversine Formula)
How to Run a PHP Script in the Background After a Form Is Submitted
How to See If a User Is Online in a Website With PHP and MySQL Driven Databases
Laravel Eloquent How to Get the Minimum Value That Is Not Null
Disable Xampp Redirect Http to Https
How to Use a Findby Method With Comparative Criteria
Combining 'Where' and 'Like' Statements by Using the Ci Activerecords