Snetty
11-01-2006, 01:04 PM
Hi there, I've been having great difficulty using regex to validate a link that's been input via a form.
I've had a look at the few examples that I've found on here (and elsewhere), but they just don't work for me. The main problem I think, is that most are not geared towards dynamic links, only static ones.
I'm not too concerned about making sure that the link is valid, just making sure that the users can only input allowed characters really.
This is what I came up with:
if (!eregi("^[[:alnum:][:punct:]\+/\?=&]{12,255}$", $_POST['link'])){
//problem
} else {
//no problem
}
Can anyone tell me what's wrong with this and why it won't work for me?
I've had a look at the few examples that I've found on here (and elsewhere), but they just don't work for me. The main problem I think, is that most are not geared towards dynamic links, only static ones.
I'm not too concerned about making sure that the link is valid, just making sure that the users can only input allowed characters really.
This is what I came up with:
if (!eregi("^[[:alnum:][:punct:]\+/\?=&]{12,255}$", $_POST['link'])){
//problem
} else {
//no problem
}
Can anyone tell me what's wrong with this and why it won't work for me?