Google+

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Conversie ereg() si eregi()
#1
Ok, incerc sa fac o conversie de la functiile ereg() si eregi() la preg_match() si nu imi prea reuseste.

PHP Code:
$good = preg_match('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.
               '@'.
               '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
               '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
               $email);	

in loc de preg_match a fost ereg(), cand am schimbat prima data a mers, dupa aia nu a mai vrut sa meara, imi da un warning
preg_match(): Unknown modifier '_'
am incercat sa adaug / / sa sfarsitul expresiei regulate, dar aceeasi chestie se intampla.


iar acsta este eregi() am citit pe net despre ea si nu imi dau seama daca modificarea pe care o fac funcioneaza sau nu

PHP Code:
if (eregi($EmailArray[$ct], $email))

conform a ceea ce am citit pe internet, ar trebui sa arate cam asa

PHP Code:
if (preg_match("/$EmailArray[$ct]/i", $email))

sau nu am inteles eu cum trebuie ?!
ceva sugestii?

Reply
#2
Ce vrei exact sa faci? Sa validezi o adresa de e-mail? Daca da, atunci acel preg match facut de tine se poate reduce la ceva mult mai simplu...
Uite un exemplu :

PHP Code:
function validare($email) {
$check = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
return eregi($check,$email));
}

Users : collective term for those who use computers. Users are divided into three types : novice, intermediate and expert.
Novice users : people who are afraid that simply pressing a key might break their computer.
Intermediate users : people who don`t know how to fix their computer after they`ve just pressed a key that broke it.
Expert users : people who break other people`s computers.
Reply
#3
am rezolvat problema
multumesc de raspuns Mihu
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)