Method RegEx():createEmail() Foundation

Creates a RegEx instance for email address validation.

Syntax
:createEmail( [<lStrict>] ) --> oRegEx
Parameters
<lStrict>
Specifies whether to use a general pattern for email validation or a strict one. The parameter defaults to .F. (false), meaning a general pattern is used which checks whether email addresses conform to the common structure which is in use today ("user@domain.tld"). This mode covers the majority of the use-cases.
When .T. (true) is assigned to the <lStrict> parameter, an alternative validation pattern is used which performs strict email address validation according to RFC 5322. This also matches email addresses using uncommon formats. This mode only ensures that a given address is technically valid by verifying the address against the specifications set forth in the RFC. There is no guarantee that the address can actually be used/processed in a given infrastructure (network, mail agent). Neither is there any guarantee that an email address that does work is actually RFC 5322-compliant. Enabling strict validation may be required when implementing software components that need to ensure technical compliance.
Return

The pre-configured RegEx object.

Description

Factory method that creates a pre-configured RegEx object for validating email addresses. Provides different validation modes which allow to specify a bias towards practical/hands-on or technical validation.

General email validation

oEmail := RegEx():createEmail() 
? oEmail:test("user@example.com") // .T. 
oEmail:destroy() 

Strict (RFC 5322) email validation

oRegEx := RegEx():createEmail( .T. ) 
? oRegEx:test( "user+name!foo%bar@[192.168.1.42]" ) // .T. 
? oRegEx:test( '"john\"doe"@example.com' )          // .T. 
oRegEx:destroy() 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.