emailLength

Does string s[] start with an email address?

ptrdiff_t
emailLength
(
Char
)
(
scope const(Char)[] s
)
if ()

Return Value

Type: ptrdiff_t

-1 it does not len it does, and s[0 .. i] is the slice of s[] that is that email address References: RFC2822

Examples

string s1 = "my.e-mail@www.example-domain.com with garbage added";
assert(emailLength(s1) == 32);
string s2 = "no email address here";
assert(emailLength(s2) == -1);
assert(emailLength("issue 14924") < 0);

Meta