preg_match help

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Help how can I force the variable to start with a character.

I dont want it to start with a number????

function alphanumeric($alphanumeric_field)
    return TRUE;
    return FALSE;

any ideas much appreciated. As i am so frustrated with the preg_match

Re: preg_match help

I forgot to mention as well that it was allowing whitespace. Which i did not

all i want is A-Z regardless of case. and Numbers. No other characters. And
start with a letter.

Quoted text here. Click to load it

Re: preg_match help

Quoted text here. Click to load it

I haven't tested this, but you probably want something along these lines:


A '^' (carat) inside of '[]' means NOT (so, '[^A-Z]' means any single  
character EXCEPT an upper-case letter). A '^' outside of '[]' means start of  

The above pattern, then, is looking for...

Start of line THEN a single alphabetic character (upper- or lower-case) THEN  
zero or more alphabetic characters (upper- or lower-case) or decimal digits  
THEN end of line (the '$' means end of line).

That's it really.


Site Timeline