BomberMan2K
Programmer
Hi guys,
I'm trying to build this little nifty form to get field names for SPSS software. The catch is it can only start with an alphachar (a-zA-z), continue with alphanumeric chars (a-z, A-Z, 0-9, _ - underscope) and can end with only alphanumeric char (not with an underscope).
suppose "val" is my input, I'm trying this regex:
if (val.match(/^([a-zA-Z]{1,}?|[a-zA-Z][a-zA-Z0-9_]+[a-zA-Z0-9])$/))
It works fine, but doesn't validate for "h1" for example (though it should). for "h_1" it does...
What is wrong with my expression here? Why doesn't it validate for "h1"?
Thank you,
Roman.
I'm trying to build this little nifty form to get field names for SPSS software. The catch is it can only start with an alphachar (a-zA-z), continue with alphanumeric chars (a-z, A-Z, 0-9, _ - underscope) and can end with only alphanumeric char (not with an underscope).
suppose "val" is my input, I'm trying this regex:
if (val.match(/^([a-zA-Z]{1,}?|[a-zA-Z][a-zA-Z0-9_]+[a-zA-Z0-9])$/))
It works fine, but doesn't validate for "h1" for example (though it should). for "h_1" it does...
What is wrong with my expression here? Why doesn't it validate for "h1"?
Thank you,
Roman.