Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

regex ?

former_member194669
Active Contributor
0 Kudos

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?

1 ACCEPTED SOLUTION

b_deterd2
Active Contributor
0 Kudos

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

4 REPLIES 4

b_deterd2
Active Contributor
0 Kudos

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

0 Kudos

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

  • +—As before, tells the parser to match on one or more word-letters

  • .—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-letters—two or three, in this case.

0 Kudos

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

b_deterd2
Active Contributor
0 Kudos

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])?"