I am trying to validate a user input PHP variable name like $as_cap['abc']
at insert time.
I have to check whether the variable name format is right or wrong. Please help me on that. Curr ently I use
eregi("^[a-z0-9_.'-]{1,50}$")
but it's not working.
regexp that matches your example and its use in javascript:
var checkResult = inputText.match(/\$[a-z_][a-z0-9_]*\[[a-z\']+\]/);
You'll probably need to add global flags and adjust it a bit in case you're using text area and there can be more occurrences of searched assignments