i need a pattern which satisfies mysql field names, but also with the option of having a table name before it
examples:
mytable.myfield
myfield
my4732894__7289FiEld
here's what i tried:
$pattern = "/^[a-zA-Z0-9_]*?[\.[a-zA-Z0-9_]]?$/";
this worked for what i needed before, which was just the field name:
$pattern = "/^[a-zA-Z0-9_]*$/";
any ideas why my addition isnt working?
maybe i'm making up regex, so i'll explain what i added... the first '?' is to say that it isn't greedy, ie. it will stop if the next part, namely "[.[a-zA-Z0-9_]]?" is satisfied. now, that second part is just the same as the first except it is optional (hence the '?' at the end) and it starts with a period (hence the '[.' and ']' wrapping my old clause. and obviously, the "^" and "$" rep the beginning and end of the string
so... any ideas?
(also, i'm a tad confused as to why i need to put in those "/"s in the begining/end anyways, so if you could tell me why it's required, that'd be awesome)
thanks a lot! (and thanks for reading this all if you actually did... it's quite a ramble)