Pass5107

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-11-02
10:24
3617 views
Has anyone written cobol code to valid entry of an email address I searched the internet on this issue and only .net, c#, and php come up?
Validating input of an email address
6 Replies
DougP

Outstanding Contributor.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-11-02
11:09
RE: Has anyone written cobol code to valid entry of an email address I searched the internet on this issue and only .net, c#, and php come up?
Here's a thread that contains code to vaildate the format of an email address:
www.mvsforums.com/.../viewtopic.php
www.mvsforums.com/.../viewtopic.php
ShanePrice

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-11-02
11:40
RE: Has anyone written cobol code to valid entry of an email address I searched the internet on this issue and only .net, c#, and php come up?
FYI, that code will flag many valid email addresses as invalid. It is designed around older USA email addresses like (someone@email.com) as long as the domain ends with ".COM", ".ORG", ".NET", or ".EDU". It doesn't accept older ".INFO" and ".GOV" domains and flags as invalid domains that include a country code (.us, .uk, .eu, etc.). It also won't work with country codes because they have a second "." character (someone@email.co.uk). In addition, there are many valid domains that exist today that don't match the old standard. Some examples include ".doctor", ".shop", ".fitness", ".dog", etc. You can view the entire list of currently valid top level domains at data.iana.org/.../tlds-alpha-by-domain.txt
The sample code from 2006 is a good starting point. Just make sure you update it to recognize the expanded list of valid domains that exist today as well as formatting to accept valid country codes.
The sample code from 2006 is a good starting point. Just make sure you update it to recognize the expanded list of valid domains that exist today as well as formatting to accept valid country codes.
Pass5107

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-11-02
13:59
RE: Has anyone written cobol code to valid entry of an email address I searched the internet on this issue and only .net, c#, and php come up?
What I am trying to do is some validation during entry to say at least check to see that only one @ sign is in the string, and at least one standard character before and after the @, and at least one period after the the @ sign. In our case, the entry person would then press an icon to send a test email to the email address with instructions to reply back that the email information is correct. We do not to be responsible for the validation other than the obvious. It sounds like I will need to review the obvious tests from those other languages and convert them to Cobol.
Thanks for the replies
Thanks for the replies
Chuck Edgin

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-11-02
18:11
RE: Has anyone written cobol code to valid entry of an email address I searched the internet on this issue and only .net, c#, and php come up?
You can find plenty of Regular Expressions on the web for validating the format of an email address.
Have a look here:
http://regexlib.com/Search.aspx?k=email
or here:
These are just a few examples, but a Google search will turn up plenty more. Once you've found a regex you're happy with, you can use it in your ACUCOBOL code using the C$RegExp library routine.
Pass5107

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-11-03
07:49
RE: Has anyone written cobol code to valid entry of an email address I searched the internet on this issue and only .net, c#, and php come up?
Thanks Chuck I will check the sights and the use of C$RegExp.

Micro Focus Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2017-11-06
09:11
RE: Has anyone written cobol code to valid entry of an email address I searched the internet on this issue and only .net, c#, and php come up?
Like pretty much all regexes for email-address validation, these are either broken or nearly impossible to maintain.
RFC 5322 allows a vast range of possible address expressions, some of which aren't actually usable in practice. This page gives a regex which the author claims accurately matches RFC 5322's "preferred" syntax:
www.regular-expressions.info/email.html
... but the author then goes on to explain why you shouldn't use it.
It also doesn't seem to support angle-addrs. Most of the regexs I've seen for this purpose don't. And, personally, my feeling is that if you don't support angle-addrs, you have a usability issue, because some MUAs like to put an angle-addr in the clipboard when you copy an email address. Not handling angle-addrs is like not allowing hyphens in credit-card numbers: you're forcing the user to do a job that the machine can do trivially.
But maintenance is the greatest concern. I use regexes every day (because vim is my editor of choice), but I try to avoid them in code. And when I do use them, I break them up into short, well-commented sections. Regular expressions are very difficult for most people to read and reason about - particularly the "extended" regular-expression syntax popularized by Perl, which defines things that are formally equivalent to Turing machines (real regexes are only DFA-equivalent) and consequently have nasty potential problems like not halting.
In this case, I don't see any good reason to use a regular expression. Implement individual tests. There aren't that many of them, and the OP listed a bunch (exactly one @ character, etc). They aren't hard. They will be very easy for a maintainer to understand and update.
RFC 5322 allows a vast range of possible address expressions, some of which aren't actually usable in practice. This page gives a regex which the author claims accurately matches RFC 5322's "preferred" syntax:
www.regular-expressions.info/email.html
... but the author then goes on to explain why you shouldn't use it.
It also doesn't seem to support angle-addrs. Most of the regexs I've seen for this purpose don't. And, personally, my feeling is that if you don't support angle-addrs, you have a usability issue, because some MUAs like to put an angle-addr in the clipboard when you copy an email address. Not handling angle-addrs is like not allowing hyphens in credit-card numbers: you're forcing the user to do a job that the machine can do trivially.
But maintenance is the greatest concern. I use regexes every day (because vim is my editor of choice), but I try to avoid them in code. And when I do use them, I break them up into short, well-commented sections. Regular expressions are very difficult for most people to read and reason about - particularly the "extended" regular-expression syntax popularized by Perl, which defines things that are formally equivalent to Turing machines (real regexes are only DFA-equivalent) and consequently have nasty potential problems like not halting.
In this case, I don't see any good reason to use a regular expression. Implement individual tests. There aren't that many of them, and the OP listed a bunch (exactly one @ character, etc). They aren't hard. They will be very easy for a maintainer to understand and update.