Assuming you meant 0-9 OR a-z ...

if (preg_match('/^[a-z0-9]/',$string))
{
    ...
}

The ^ in the regular expression anchors it to the start of the string.  
Similarly, if you wanted to check that the string ENDED with the same 
criteria then you would anchor the test to the end of the string with a $.

if (preg_match('/[a-z0-9]$/',$string))

B.

Michael wrote:
> What would be the best way to check that the first character in a string is 
> only 0-9 and a-z?
>
> Thanks in anticipation. :-)
>
> Michael
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to