You can solve this by making the first digit different from 0 with '/^[1-9][0-9]*$/'
With your list of examples:
foreach (array('1', '50', '333', '0', '01', 'abc') as $var) { echo $var.': '.(preg_match('/^[1-9][0-9]*$/', $var) ? 'true' : 'false')."\n"; }
This script gives the following results:
$ php test.php 1: true 50: true 333: true 0: false 01: false abc: false
source share