Another expression which puzzles me, reading a teach yourself php book:
It's to check whether a person's name is input correctly. The book says: "If we say that a name can contain letters, a "-"character, spaces and has at least several letters and cannot start with a space or "-" character, than we can define the expression als follows"
^[A-Za-z. -]+$
I would read this like this: string starts and ends with one or more upper or lower case letters, a random character ("."), a space character and a "-" character. Am I wrong thinking this?
Anyway, I don't see the "cannot start with a space or "-" character" part in this expression. I was thinking that it might be something like this:
^([^ -][A-Za-z. -])+$
but I'm not sure this is correct? It should start with a space or "-" character, but space or "-" character should be allowed somewhere in between.