Thanks Kevin for the UPPER function suggestion. But, I didn’t realise that I am calling MATCH with MATCH:Regular + Match:NoCase as this test app was done a few years ago. Therefore a-zA-Z is already being ignored.
using this regex string Latest Expression:
^[A-Z0-9!#$%&\’+/=?^{|}~-][A-Z0-9!#$%&\’*+/=?^{|}~-]+{[?.][A-Z0-9!#$%&\’+/=?^_{|}~-]+}@[A-Z0-9-]+{[?.][A-Z0-9-]+}[A-Z0-9]$
I am not an expert in Regex so could anyone give me the correct syntax, please?
tried this but it doesn’t work ^[A-Z0-9!#$%&'*+/=?^_'{|}~-]+(?:\.[A-Z0-9!#$%&'*+/=?^_'{|}~-]+)*@(?:[A-Z0-9](?:[A-Z0-9-]*[A-Z0-9])?\.)+[A-Z0-9](?:[A-Z0-9-]*[A-Z0-9])?$
Match:NoCase … Therefore a-zA-Z is already being ignored.
I’m pretty certain Match:NoCase only applies outside of [sets] so [A-Za-z] is required to match both upper and lower case letters. The easier way for NoCase is to UPPER(email) as Kevin had so you only need sets with [A-Z]
I wonder about this part: {[?.][A-Z0-9-]+}
You’re saying an email can have a [Question Mark or Period] once, then [Letters/Numbers/Dash] 1 or more times?
An email can use a ? in the Domain instead of a Period?
Maybe [?.] would be more correct as a Backslash-Period an Escaped Period to indicate a Period?
I thought domains always ended with Period 2+ letters or numbers like .com or .co.uk: .[A-Z0-9][A-Z0-9]+
I am talking about MatchExpression.zip example (attached here) and RegEx expression used there. So the problem is that using this regex string Latest Expression (see above)
That’s easy if you look at your expression split into parts like below in line 2 it requires 1 character from the set [a-z] , plus line 3 requires “+” (1 or more) from the next set ([a-z]+) so you require 2 before any period (or question mark)
I do not have the Email spec memorized and this is a complicated expression, maybe too complicated. Are trying to prevent invalid use of the period like … @. .@ ? I would do that separately. This is untested:
IF MATCH('^\.|\.$',Eml,Match:Regex) THEN ! No .billg@m
Message('Cannot begin or end with a period')
...
P=STRPOS('\.\.|\.@|@\.',Eml) ! No .. .@ @.
IF P THEN
MESSAGE('Invalid Period at position ' & P & ': ' & SUB(Eml,P,2)
…
Maybe then your expression before the @ can be simpler.
I would suggest on your Window you add a TEXT control so you can work on the separate lines more easily (like my 1 to 9 above). PROP:LineCount and PROP:Line can be used to get the lines and concat into a single string.
In sets the hyphen should be first so [A-Z0-9-] as [-A-Z0-9]
Below worked for me, except it does not catch the … .@ that I would do separately. I added Underscore. Not sure why you have ? or . so changed [?.] to backslash-period. Is Name@Domain with no .xx suffix valid?
If this will be used to tell a user Message(‘Email entry is invalid’) I would split checking into parts so messages make it obvious where the problem is so you don’t create puzzle for the user nor tech support.
Tell them they have a space at position X. You could just quietly take out spaces but I wouldn’t.
Check for a single @
Check for invalid periods
Validate before the @
Validate after the @
It’s not I have it - this was original regex from the attached example. Honestly speaking I have no idea how does regex work and used example in my project.
Thank you for your detailed answer - I will follow it and try to figure out
1 - +/=?^{|} I have +/=?^{|} – Notice _ after the ^
2 - +/=?^{|} I have +/=?^{|} – Notice _ after the ^
3 - ]+}@[A- I have ]+}@[A- – Notice * after the }
4 - ]+}[A-Z I have ]+}[A-Z – Notice * after the }