[REBOL] Re: Check email syntax
From: tomc::darkwing::uoregon::edu at: 31-Jan-2004 20:07
hello Arnaud
a minimal email DNS checker could be as simple as
read join dns:// next find email "@"
but if you really want a maximal validating parser per RCF821 ...
you can make some rules, these were derived from
http://www.freesoft.org/CIE/RFC/821/15.htm
a: charset [#"A" - #"Z" #"a" - #"z"]
d: charset {0123456789}
special: charset [ #"^(00)" - #"^(1F)" #"^(7F)"
#"<" #">" #"(" #")" #"[" #"]" #"\" #"." #"," #";" #":" #"@" #"^""
]
snum: [["25" ["0" | "1" | "3" | "4" | "5"]] |
["2" ["0" | "1" | "3" | "4"]d] |["1" 2 d] | [1 2 d]
]
qc: complement charset [#"^(10)" #"^(13)" #"^"" #"\"]
c: complement union special charset " "
x: ["\" skip]
dotnum: [snum "." snum "." snum "." snum]
number: [some d]
let-dig: union a d
ldh-str: [some [let-dig | "-"]]
name: [a ldh-str]
element: [["#" number] | ["[" dotnum "]"] | name]
domain: [element any ["." element]]
qtext: [some [qc |x ]]
char: [c | x]
string: [some char]
quoted-string: ["^"" qtext "^""]
dot-string: [[string "." dot-string] | string]
local-part: [dot-string | quoted-string]
mailbox: [local-part "@" copy dmn domain (dns: read join dns:// dmn)]
; to use these rules ...
email: [r3b0l--free--fr]
dns: none
parse/all email mailbox
dns
HTH
On Sat, 31 Jan 2004 [r3b0l--free--fr] wrote: