Haxor
Haxor

Reputation: 631

Using preg_match()

Only binary digits upto 8 digits

(preg_match("/^[0-1]{1,8}$/", $binary)

How to make a preg_match() that is upto 11 digits only that starts only with 09 and 63?

(preg_match('/^[!{09}|{63}]/', $mobile)

Problem is only 09 and 63 should start first, and do not exceed at 11 digits.

Upvotes: 0

Views: 154

Answers (2)

Im0rtality
Im0rtality

Reputation: 3533

/^(09|63)[\d]{9}$/m

Tested with:

09999999999 => pass
63999999999 => pass
11999999999 => fail
63aaaaaaaaa => fail
09bbbbbbbbb => fail

http://regex101.com/r/kM8kF9

Upvotes: 1

Sabuj Hassan
Sabuj Hassan

Reputation: 39443

This should work for you:

preg_match("/^(?:63|09)[0-1]{0,8}$/", $binary)

Upvotes: 0

Related Questions