04-01-2008 3:20 PM
Hi,
I am doing a validation for valid mail-ids thru REGEX . Here is the code for this . but it is not giving any results back.
report zars.
data: regex type ref to cl_abap_regex,
matcher type ref to cl_abap_matcher,
match type c length 1.
create object regex exporting pattern = ' [A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4} '
ignore_case = ''.
matcher = regex->create_matcher( text = '"abc^abc.ca"' ).
match = matcher->match( ).
write match.
Any Info?
a®
04-01-2008 4:32 PM
Did you try using an alternative pattern like:
[a-z0-9!#$%&'/=?^_`{|}~-](?:\.[a-z0-9!#$%&'/=?^_`{|}~-])@(?:[a-z0-9](?:[a-z0-9-][a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
Hope it helps,
bert
04-01-2008 4:32 PM
Did you try using an alternative pattern like:
[a-z0-9!#$%&'/=?^_`{|}~-](?:\.[a-z0-9!#$%&'/=?^_`{|}~-])@(?:[a-z0-9](?:[a-z0-9-][a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
Hope it helps,
bert
04-01-2008 4:45 PM
Thanks for your reply. Your reply give me a hint to solve this issue
I tried in this way
[w]+@[w]+.[w]{2,3}
Here is the details:->
The w represents any word-letter (A-Z,a-z and 0-9). This is then bracketed so that the plus modifier can be used to specify one or more. Therefore, tells the parser to match on one or more word-letters.
@Tells the parser to look for the at-sign@character
.Match on the period character
{2,3}Once again, the pattern specifies a search for word-letters with the difference here being that the {x,y} modifier tells the parser to search for a specific number of word-letterstwo or three, in this case.
a®
04-01-2008 5:02 PM
For more related regex pattern please refer this link
http://www.grymoire.com/Unix/Regular.html#uh-0
and please remember POSIX characters will be validated from
version ECC 7.00 onwards
a®
04-01-2008 4:37 PM
this looks better!
"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"