Reputation: 12047
$output = preg_replace( '/[^0-9]/', '', $string );
How can I change the above line to only accept 11 digit
long numbers that must start with either 01, 02, 03, 05, 07 or 08, but NOT 04, 06, 09
?
Upvotes: 0
Views: 506
Reputation: 4872
Try this:
^0[1-3578]\d{9}$
0
-Zero [^469]
-Number except 469 \d
-Any Number
Upvotes: 0
Reputation: 39355
Try this one:
$output = preg_replace( '/^0[1-3578]\d{9}/', '', $string );
\d{9}
means 9 digits as you have already 2 digits back.
Upvotes: 2