Jump to content

Regex help! Only numbers and "/"


hannibal

Recommended Posts

Hi

 

I have some code whihc I am trying to exclude several characters:

 

if (!preg_match("/^([a-z0-9._-](\+[a-z0-9])*)", $_POST["code"])){

    // Raise error message = FAIL

} else {

    // We are A OK.

}

 

In fact, all I want the user to be able to submit are "0-9a-z/_" (i.e. no spances, or dots or other special characters). I want to also esure that the first character is not a "/".

 

But it always fails if I have "/" in my code and I cannot understand why.

 

Any ideas anyone? Thanks in advance.

 

H.

Link to comment
https://forums.phpfreaks.com/topic/94486-regex-help-only-numbers-and/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.