validate an email or url

This should be close for email, it assumes email must end with period and two or more letters, I think that’s correct.

IF
~MATCH(emailaddress,'^[-a-zA-Z0-9._]+@{{[-a-zA-Z0-9.]+\.}+[a-zA-Z][a-zA-Z]+$',Match:Regular+MatchNocase)
    Message('looks like a bad address buddy')
END

Email must contain:
[a-z A-Z 0-9 or -._ ] 1 or more times
@
[a-z A-Z 0-9 or -._ ] 1 or more times
a period which is \.
then two letters or more, I think it should be limited to 2,3 or 4

Could simplify a little with UPPER ( [character sets] are case sensitive even if MatchNocase)

IF
~MATCH(UPPER(emailaddress),'^[-A-Z0-9._]+@{{[-A-Z0-9.]+\.}+[A-Z][A-Z]+$',Match:Regular)
    Message('looks like a bad address buddy')
END

To allow only ending with 2,3 or 4 bytes change .[A-Z][A-Z]+$ to [A-Z][A-Z][A-Z]?[A-Z]?$

At ClaMag is an article about Match and includes a Match explorer App to help you play with Match. Note the double curly {{ is required in Clarion source but would not in Match Explorer. Also my Clarion Source Search utility has a Regular Expression helper.

—————————————————
Carl Barnes [Team SoftVelocity]
www carlbarnes com – Carlng@–myname.com–
Maker of CW Assistant and Clarion Source Search Utilities

Schreibe einen Kommentar