Naviguation dans :  Perl  JavaScript  Détail  - load.cgi?Appel=extractAdmin
 présentée :  par cas d'appel   par traitements 
Retour à l'accueil
  
     
 Requêtes 

 load – Admin 

 extractAdmin 

Requêtes de Ça-déménage.com
Accès professionnel
Extraire des données
  
 
 Bibliothèque CaD 

 Serveur 

 wsRunVar 

Bibliothèque de Ça-déménage.com
Paramètres d'accès au serveur
Paramètres de gestion des valeurs
 
  
  
 Bibliothèque 

 Mail 

 tstEmail 

Bibliothèque standard
Divers utilitaires de gestion des mails
Teste la validité syntaxique d'une adresse e-mail
  


 tstEmail  Teste la validité syntaxique d'une adresse e-mail
Syntaxe tstEmail(x)
Paramètres 
nom  type  Description 
 IN Adresse e-mail à tester
retourne  OUT  0 : Adresse correcte
1 : Adresse incorrecte
Fonctions util. Néant


Code Perl 

sub tstEmail {local($x) = @_; 
 if ($x eq '') {return 1}
while(true) {
 if ($x!~/^([\w_\-]+)/) {return 1}; if ($x eq $1) {last}; $x = substr($x,length($1));
 if ($x eq '.') {return 1}; if (substr($x,0,1) ne '.') {last}; $x = substr($x,1)
}
 if ($x eq '@') {return 1}; if (substr($x,0,1) ne '@') {return 1}; $x = substr($x,1);
 if (index($x,'.')==-1) {return 1};
if (substr($x,0,1) eq '[') {
 if ($x!~/^(\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])/) {return 1}; if ($x ne $1) {return 1}
} else {
while(true) {
 if ($x!~/^([\w_\-]+)/) {return 1}; if ($x eq $1) {last}; $x = substr($x,length($1));
 if ($x eq '.') {return 1}; if (substr($x,0,1) ne '.') {last}; $x = substr($x,1)
}
 if ($x!~/^([a-zA-Z]{2,})/) {return 1}; if ($x ne $1) {return 1}
}
 return 0
}
Code JavaScript 

function tstEmail(x) { 
 if (x=='') {return 1}
while(true) {
 if (!x.match(/^([\w_\-]+)/)) {return 1}; if (x==RegExp.$1) {break}; x = x.substr(RegExp.$1.length);
 if (x=='.') {return 1}; if (x.substr(0,1)!='.') {break}; x = x.substr(1)
}
 if (x=='@') {return 1}; if (x.substr(0,1)!='@') {return 1}; x = x.substr(1);
 if (x.indexOf('.')==-1) {return 1};
if (x.substr(0,1)=='[') {
 if (!x.match(/^(\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])/)) {return 1}; if (x!=RegExp.$1) {return 1}
} else {
while(true) {
 if (!x.match(/^([\w_\-]+)/)) {return 1}; if (x==RegExp.$1) {break}; x = x.substr(RegExp.$1.length);
 if (x=='.') {return 1}; if (x.substr(0,1)!='.') {break}; x = x.substr(1)
}
 if (!x.match(/^([a-zA-Z]{2,})/)) {return 1}; if (x!=RegExp.$1) {return 1}
}
 return 0
}