php - question about preg_match

cooky

New Member
I need to define a pattern so that the input string can only contain 0-9, a-z, and A-Z. Also, the length is in the range of 1-30.Here is the script:\[code\]$fileBaseName = 'abc12345';if (!preg_match("/^[a-zA-Z0-9]{1, 30}$/", $fileBaseName)) { echo '<br/>' . 'invalid' . '<br/>';} else { echo '<br/>' . 'valid' . '<br/>';}\[/code\]However, when I run this code, the return always is 'invalid'.How to fix this issue?Thank you
 
Back
Top