× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



All,

 It seemed that verifying email addresses with Regular Expressions would be
a good learning exercise, but so far all I've accomplished is to waste the
better part of a day. We already have email validation routines in place so
this project is really about learning REs. Would someone be kind enough to
take a look at this before I chuck the whole thing and go back to doing
something productive in RPG?

Background: Running a plain-vanilla V5R3 US QCCSID=37 machine. ScottK's
excellent REDEMO program runs fine so I believe the basic configuration is
correct. The following code works as expected:

RegPattern = 'test';
rc = regcomp(reg: %trimr(RegPattern): REG_BASIC+REG_ICASE+REG_NOSUB);
// regexec works l/c
Chr256 = 'test@xxxxxxxxxxx';
rc = regexec(reg: %trim(Chr256): 0: match: 0);
// regexec works u/c
Chr256 = 'TEST@xxxxxxxxxxx';
rc = regexec(reg: %trim(Chr256): 0: match: 0);
// regexec correctly fails this one
Chr256 = 'SHOULDFAIL@xxxxxxxxxxx';
rc = regexec(reg: %trim(Chr256): 0: match: 0);

Problem: The following pattern works correctly on web-based RE engines and
compiles without error in my test program, but won't match test strings when
called from RPG.

// From: http://www.regular-expressions.info/email.html 
RegPattern = '^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$';
rc = regcomp(reg: %trimr(RegPattern): REG_BASIC+REG_ICASE+REG_NOSUB);
// Why won't this work?!?                      
Chr256 = 'test@xxxxxxxxxxx';                   
rc = regexec(reg: %trim(Chr256): 0: match: 0);
 
My suspicions center on RPG mis-interpreting the '^' character in the
pattern, but I'm not sure how to verify it or fix the problem. Does anyone
have suggestions how to make this RE work correctly? Many thanks, JK



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.