Jump to content

Eregi or Regi?


podja

Recommended Posts

<?php
$username = 'test5-3_4';
if (preg_match('{^[\w\d-]+$}', $username) )
	echo 'valid';
else
	echo 'invalid';
?>

^ means it has to begin from the first sign on. In my example from t

\w is the same as A-Za-z_

\d is the same as 0-9

$ means it has to be the last sign... so test5-3_4 & is invalid

Link to comment
https://forums.phpfreaks.com/topic/46400-eregi-or-regi/#findComment-227427
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.