Confirm mobile phone number with regular expression

I need to check my mobile number. My need:

  • The number can start with +8801 or 8801 or 01
  • The next number may be 1 or 5 or 6 or 7 or 8 or 9
  • Then there are exact 8 digits.

How can I write a regex using these conditions?

mobile numbers i tried

+8801811419556
01811419556
8801711419556
01611419556
8801511419556
+6
source share
7 answers

It should be pretty simple:

^(?:\+?88)?01[15-9]\d{8}$
  • ^ - From the beginning of the line
  • (?:\+?88)?- optional 88, which may begin with+
  • 01 - mandatory 01
  • [15-9] - "1 or 5 or 6 or 7 or 8 or 9"
  • \d{8} - 8 digits
  • $ - end of line

Working example: http://rubular.com/r/BvnSXDOYF8

+23
source

.

1:

/(^(\+88|0088)?(01){1}[56789]{1}(\d){8})$/

Robi, Grameen, Banglalink, Airtel Teleletalk.

2:

 /(^(\+8801|8801|01|008801))[1|5-9]{1}(\d){8}$/

Citycell, Robi, Grameen, Banglalink, Airtel Teleletalk.

+8801812598624

008801812598624

01812598624

01712598624

01919598624

01672598624

01512598624

................

.................

+3

,

regex pal

[8] * 01 [15-9]\d {8}

+1

, , , @G. . . , libphonenumber Google. Java, ++ Javascript, fork PHP , , .

+880 , . Javascript:

String bdNumberStr = "8801711419556"
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
    //BD is default country code for Bangladesh (used for number without 880 at the begginning)
    PhoneNumber bdNumberProto = phoneUtil.parse(bdNumberStr, "BD");
} catch (NumberParseException e) {
    System.err.println("NumberParseException was thrown: " + e.toString());
}
boolean isValid = phoneUtil.isValidNumber(bdNumberProto); // returns true

(, "880 17 11 41 95 56" ) 00880 (+ 00).

. .

+1

Take a look at libphonenumber at: https://code.google.com/p/libphonenumber/

0
source

Bangladeshi phone number (Citycell, Robi, Grameen Phone, Banglalink, Airtel and Teletalk operators) checks using regular expressions:

$pattern = '/(^(\+8801|8801|01|008801))[1-9]{1}(\d){8}$/';
$BangladeshiPhoneNo = "+8801840001417";

if(preg_match($pattern, $BangladeshiPhoneNo)){
    echo "It is a valid Bangladeshi phone number;
}
0
source
**Laravel Bangladeshi Phone No validation for (Citycell, Robi, Grameen Phone, Banglalink, Airtel and Teletalk) and start with +88/88 then 01 then 356789 then 8 digit**  



public function rules()
        {
            return [

                'mobile' => 'sometimes|regex:/^(?:\+?88)?01[35-9]\d{8}$/',

            ];
        }

        public function messages()
        {

                'mobile.regex' => 'Mobile no should be bd standard',
            ];
        }
0
source

All Articles