Jump to content

regex problem


oracle259

Recommended Posts


I have the following regex in my script that is supposed to allow only numbers and letters but for some reason it keeps allowing symbols #$%^*. etc

How can i stop this

[code]
$pattern = "/^(?=.*?[0-9])(?=.*?[a-zA-Z])[a-zA-Z0-9]*$/i";
          $is_pattern = preg_match($pattern, $hash);
          if (!$is_pattern) {
          echo $is_pattern."  Failure";
          } else { echo $is_pattern."  Pass";
       
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/25745-regex-problem/
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.