Einzelnen Beitrag anzeigen

Benutzerbild von dummzeuch
dummzeuch

Registriert seit: 11. Aug 2012
Ort: Essen
1.623 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#3

AW: E-Mail Adresse auf Gültigkeit überprüfen

  Alt 17. Aug 2023, 09:13
Google Bard behauptet, diese RegEx sei dafür geeignet:

Delphi-Quellcode:
function ValidateEmail(const Email: string): Boolean;
var
  Regex: TRegEx;
begin
  Regex := TRegEx.Create('^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,6}$');
  Result := Regex.Exec(Email);
end;
Zitat:
Zitat:
Does this also work for umlaut domains and all kinds of local parts used e.g. in China?
Yes, the regular expression pattern I provided is also compatible with umlaut domains and all kinds of local parts used in China. This is because the pattern only specifies the characters that are allowed in the local part and the domain part, and does not make any distinction between different languages.

For example, the following email addresses are all valid according to the regular expression pattern:

test@äpfel.de (umlaut domain)
张三@qq.com (Chinese local part)
中文@126.com (Chinese local part with spaces)
However, it is important to note that not all email providers support all characters. For example, some providers may not support umlauts in the local part. So, it is always a good idea to test an email address with the actual email provider before sending an email to it.

Here are some additional resources that you may find helpful:

RFC 5322: Internet Message Format: https://tools.ietf.org/html/rfc5322
Regular Expressions Tutorial: https://www.regular-expressions.info/tutorial.html
Ehrlich gesagt, bin ich da skeptisch. Ich habe schon so häufig RegEx-Strings gefunden, die E-Mails validieren sollen, die dann doch irgendwo versagt haben.

Hier ist z.B. eine Liste von E-Mail Adressen, mit denen man testen kann:

https://gist.github.com/cjaoude/fd9910626629b53c4d25
Thomas Mueller
  Mit Zitat antworten Zitat