Search code examples
phpregexvalidationalphanumericwhitelist

Check if string only contains alphanumeric and dot characters


I need to check to see if a variable contains anything OTHER than a-z, A-Z, 0-9 and the . character (full stop).


Solution

  • if (preg_match('/[^A-Z\d.]/i', $var))
      print $var;