Jump to content
php.lv forumi

preg_match


dAivEd

Recommended Posts

e-pastos ir atļauts arī, piemēram, punkts. Ar šādu regulāro izteiksmi tev derīgs e-pasts būs arī teksts "something@", kas ne tuvu nav līdzīgs korektam e-pastam. Priekš e-pasta validācijas iesaku vienkārši paskatīties php.net dokumentācijas komentāros pie šīs pašas preg_match funkcijas.

Link to comment
Share on other sites

me agree 2 Kaklz

es tik atbildēju uz tiešo jautājumu ;)

 

pats lietoju šādu email patternu

define('PN_EMAIL', '/^[a-z0-9_.-]+@[a-z0-9_.-]+\.[a-z]{2,3}$/i');

PN - pattern ("mikro nosaukums" manā stilā :D:D:D)

Edited by 2easy
Link to comment
Share on other sites

oops, tomēr vajadzēs :D

 

tie 6x chari ir for .museum un .travel

http://iana.org/domains/root/db

 

kr4 tur ar to skaitu nav vērts cīnīties. vnk + ftw :))

"for future compatiblity"

 

tāpēc final update (i hope)

define('PN_EMAIL', '/^[a-z0-9_.-]+@[a-z0-9_.-]+\.[a-z]+$/i');

turklāt filter_var() arī to atļauj ;)

var_dump(filter_var('[email protected]', FILTER_VALIDATE_EMAIL, FILTER_FLAG_SCHEME_REQUIRED));

btw, šajā piemērā var labi redzēt, cik php ir consistent naming

var_dump()

filter_var()

brīnišķīgi! :D:D:D

Edited by 2easy
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...