Forum Moderators: phranque
I want to validate a query string using a whitelist, so if a character is not on the 'ok' list, the string is rejected. The problem is, I can't get my expression to work *properly*.
I want to have a string using alphanumeric characters and possible followed by a single slash and a number. (the slash can't be the first or last character)
so alpha_bet
or alpha_bet/10
The rejected ones could be:
alpha_bet/10/
alpha_bet/%2e%2e%2f
etc.
Here's what I have so far:
if( ereg( "[^a-zA-Z0-9_]+?([^\/([0-9]+))", $id ) )
This rejects the valid alpha_bet/10, but allows two slashes. I have no idea what to do because it looks right to me, and Google has only brought up tutorials that seem to validate my false assumption.
All help would be greatly appreciated.