I've noticed that a lot of regular expressions allow invalid characters to be added to the beginning and end of a string, posing a serious security risk if you use regular expressions to validate data... for instance:
"(0-9a-zA-Z)+" allows alphanumeric characters only... or does it?
As long as you have a digit or letter from a-z (or A-Z) somewhere in your input, anything else can get through simply by appending it to the end or beginning of the string...
so I write the above expression as follows:
"([0-9a-zA-Z]+)([0-9a-zA-Z]+)$"
which basically says that the string has to begin AND end with alphanumeric characters...
Does anyone know of a way around the long-winded version that I came up with?