By using the {x,y} operator in a regular expression, the last thing before it should be repeated any number of times that is in the range of "x to y".
For example, to do what you said, this would be used:
preg_match('/^[a-zA-Z0-9]{0,50}$/', $string);