Bonjour,
Voici un bout de code qui permet de detecter les emails dans un texte.
Je ne sais pas pourquoi il ne fonctionne pas car il retourne une valeur trop longue exemple : "dupont@hotmail.com textentrop".
Si vous pouviez m'aider. De plus j'ai une fonction while qui detecte la fin et le debut de l'adresse email part un caractère spéciaux. Si vous avez mieux à me proposé je suis preneur car elle me semble pas très optimisé !
Merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 procedure DetecteEmail(data: string); var Index,i,j : integer; Texte,tmp: string; begin Texte:=data; Index:= pos('@',Texte); While Index <> 0 do Begin i:=Index; While (Texte[i] <> ';')and(Texte[i] <> '"')and(Texte[i] <> '''')and(Texte[i] <> '>')and(Texte[i] <> '&')and(Texte[i] <> ' ')and(Texte[i] <> '!')and(Texte[i] <> '%')and(i < length(Texte)) do inc(i); if i-Index < 20 then begin j:=Index; While (Texte[j] <> ';')and(Texte[j] <> '"')and(Texte[j] <> '''')and(Texte[j] <> '>')and(Texte[j] <> '&')and(Texte[j] <> ' ')and(Texte[j] <> '!')and(j <> 1) do j:=j-1; if Index-j < 20 then begin tmp:=Copy(Texte,j,i); AjouterEmail(tmp); Delete(Texte,1, i); end; end; Index:= pos('@',Texte); end; end;
Partager