Posts: 514
Joined: Sun Oct 16, 2005 03:32 AM
Re: Validar e-mail usando Regex (SOLUCIONADO)
Posted: Sun Feb 04, 2024 03:58 AM
#Include "FiveWin.ch"
#include "hbcompat.ch"
Function Inicio()
MsgInfo(cValToChar(validaEmail("tuemail@tuservidor.com"))) // .T.
MsgInfo(cValToChar(validaEmail("tuemail$tuservidor.com"))) // .F.
MsgInfo(cValToChar(validaEmail("tuemail@tuservidor%com"))) // .F.
MsgInfo(cValToChar(validaEmail("tuemail@tuservidorcom"))) // .F.
MsgInfo(cValToChar(validaEmail("tuemail@tuservidor"))) // .F.
etc, etc, etc
Return(NIL)
function validaEmail(cEmail)
LOCAL pCompiled := hb_regexComp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$")
LOCAL aMatch
LOCAL lRet := .t.
aMatch = hb_regex( pCompiled, alltrim(cEmail) )
if Empty( aMatch )
lRet := .f.
end
return lRet
Saludos,
Carlos Gallego
*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***