Jump to content
php.lv forumi

preg_match


edi

Recommended Posts

ar tavu piemeru meginot izvada erroru :)

 No ending delimiter '^'

sadi meginot preg_match("/^[a-z][0-9a-z]*$/", $reg_nick) nekadas reakcijas

sadi preg_match("/[^a-z][0-9a-z]*$/", $reg_nick) rada ka visi ir skaitli :D

un sadi preg_match("/[^\da-z][0-9a-z]+/", $reg_nick) neko nerada (:

 

if (preg_match("/^[a-z][0-9a-z]*$/", $reg_nick)) 	$error = $error . 'Logins nevar sastāvēt tikai no cipariem!<br/>';

 

tad ka bus pareizi? :D

Edited by edi
Link to comment
Share on other sites

Ko sāsti, ka manējais nestrādā?

 

var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "MansSuperniks"));
var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "34543"));
var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "IrOk342354"));
var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "34432NavOk"));
var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "s34432Na45vOk567"));

 

Viss strādā kā nākas! (manā gadījumā, niks nevar sākties ar ciparu)

Edited by briedis
Link to comment
Share on other sites

Ko sāsti, ka manējais nestrādā?

 

var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "MansSuperniks"));
var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "34543"));
var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "IrOk342354"));
var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "34432NavOk"));
var_dump(preg_match('/^[a-zA-Z][0-9a-zA-Z]*$/', "s34432Na45vOk567"));

 

Viss strādā kā nākas! (manā gadījumā, niks nevar sākties ar ciparu)

 

$reg_nick = '34432NavOk';
if (preg_match("/^[a-zA-Z][0-9a-zA-Z]*$/", $reg_nick))
	$error = $error . 'Logins nevar sakties ar ciparu!<br/>';

 

tu neticesi :D izgaja cauri

Link to comment
Share on other sites

Es tiešām neticēšu! Jo man neiet cauri :)

 

Ieteikums - visiem IF'iem lieto {} iekavas, lai izvairītos no pārpratumiem nākotnē :)

 

 <?php $reg_nick = '34432NavOk'; if (preg_match("/^[a-zA-Z][0-9a-zA-Z]*$/", $reg_nick)) { echo 'error'; } ?> 

izmegini. tev error izvadija?

pamaniju ka vins vispar preteji dara.... ja niks nesakas ar skaitli tad error :D

Edited by edi
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...