eberswine
eberswine

Reputation: 1224

Using preg_match to accept @ too

Having a tough time.. this should be easy for you NINJA's out there.

Here is part of my function:

  if (strlen($_POST['uname']) < 3 || strlen($_POST['uname']) > 30 || !preg_match("/^([0-9A-Za-z])+$/i", $_POST['uname']) || $uname != 2)

We would want to include email address too, but can't figure out how to include the "@" symbol too ??

THanks in advance!!

Upvotes: 0

Views: 29

Answers (1)

Christophe Maggi
Christophe Maggi

Reputation: 132

If I understad what you want : !preg_match("/^([\W])+$/i" or maybe use posix :

<?php
$regex = '[[:punct:]]';

if (preg_match('/'.$regex.'/', 'somepas$', $matches)) {
    print_r($matches);
}
?>

Upvotes: 2

Related Questions