<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Validate Email by regular Expression... Need Help in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899340#M1596620</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Requirement: &lt;/P&gt;&lt;P&gt;validate the email ID entered &amp;amp; throw error message, if it is invalid.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA c_mailpattern TYPE c LENGTH 60 VALUE
'[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4} '.

** If @ is present, more than once. Error out
    find ALL OCCURRENCES OF '@' in P_email
    MATCH COUNT v_count.
    if v_count &amp;gt; 1.
      v_badpattern = 1.
    endif.

** If , is present, once, Error out
    find ALL OCCURRENCES OF ',' in P_Email
    MATCH COUNT v_count.
    if v_count &amp;gt; 0.
      v_badpattern = v_badpattern + 1.
    endif.
    FIND REGEX c_mailpattern IN P_Email IGNORING CASE .

    IF sy-subrc &amp;lt;&amp;gt; 0 OR v_badpattern &amp;gt; 0.
Write:/ p_EMAIL, 'has invalid Email format'.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;though this works fine, tester needs me to catch, if domain name has "app.com.com"  as invalid email id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;above regex fails in such case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I searched &amp;amp; found &lt;/P&gt;&lt;P&gt;{messageID=3706355}&lt;/P&gt;&lt;P&gt;messageID=1657369}{&lt;/P&gt;&lt;P&gt;&lt;A href="https://wiki.sdn.sap.com/wiki/display/Snippets/E-MAIL+Validation" target="test_blank"&gt;https://wiki.sdn.sap.com/wiki/display/Snippets/E-MAIL+Validation&lt;/A&gt;&lt;/P&gt;&lt;P&gt; doesn't help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found this regex in a perl program.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
[a-z0-9!#$%&amp;amp;'{size:14}*+{size:14}/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can I get help to modify this  into ABAP String?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) I can't bypass the boldened text using Escape characters like #* or '' Can some one help me assign this regex-string into a string variable?&lt;/P&gt;&lt;P&gt;2) This regex is longer than allowed length for a literal.&lt;/P&gt;&lt;P&gt;It can be split into 2 strings, then concatenated &amp;amp; checked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Mallikarjuna J on May 16, 2011 8:23 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Mallikarjuna J on May 16, 2011 8:26 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 May 2011 14:52:10 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-05-16T14:52:10Z</dc:date>
    <item>
      <title>Validate Email by regular Expression... Need Help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899340#M1596620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Requirement: &lt;/P&gt;&lt;P&gt;validate the email ID entered &amp;amp; throw error message, if it is invalid.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA c_mailpattern TYPE c LENGTH 60 VALUE
'[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4} '.

** If @ is present, more than once. Error out
    find ALL OCCURRENCES OF '@' in P_email
    MATCH COUNT v_count.
    if v_count &amp;gt; 1.
      v_badpattern = 1.
    endif.

** If , is present, once, Error out
    find ALL OCCURRENCES OF ',' in P_Email
    MATCH COUNT v_count.
    if v_count &amp;gt; 0.
      v_badpattern = v_badpattern + 1.
    endif.
    FIND REGEX c_mailpattern IN P_Email IGNORING CASE .

    IF sy-subrc &amp;lt;&amp;gt; 0 OR v_badpattern &amp;gt; 0.
Write:/ p_EMAIL, 'has invalid Email format'.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;though this works fine, tester needs me to catch, if domain name has "app.com.com"  as invalid email id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;above regex fails in such case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I searched &amp;amp; found &lt;/P&gt;&lt;P&gt;{messageID=3706355}&lt;/P&gt;&lt;P&gt;messageID=1657369}{&lt;/P&gt;&lt;P&gt;&lt;A href="https://wiki.sdn.sap.com/wiki/display/Snippets/E-MAIL+Validation" target="test_blank"&gt;https://wiki.sdn.sap.com/wiki/display/Snippets/E-MAIL+Validation&lt;/A&gt;&lt;/P&gt;&lt;P&gt; doesn't help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found this regex in a perl program.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
[a-z0-9!#$%&amp;amp;'{size:14}*+{size:14}/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can I get help to modify this  into ABAP String?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) I can't bypass the boldened text using Escape characters like #* or '' Can some one help me assign this regex-string into a string variable?&lt;/P&gt;&lt;P&gt;2) This regex is longer than allowed length for a literal.&lt;/P&gt;&lt;P&gt;It can be split into 2 strings, then concatenated &amp;amp; checked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Mallikarjuna J on May 16, 2011 8:23 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Mallikarjuna J on May 16, 2011 8:26 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 May 2011 14:52:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899340#M1596620</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-16T14:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Validate Email by regular Expression... Need Help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899341#M1596621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check this sample program, it works for me&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PARAMETERS p_valor TYPE c LENGTH 30 LOWER CASE.
*PARAMETERS p_regex TYPE c LENGTH 500 visible length 500.
DATA: l_pat(500) type c.


DATA matcher TYPE REF TO cl_abap_matcher.



l_pat = '^[\w\.=-]+@[\w\.-]+\.[\w]{2,3}$'.

matcher = cl_abap_matcher=&amp;gt;create( pattern =  l_pat"p_regex

ignore_case = 'X'
text = p_valor ).
IF matcher-&amp;gt;match( ) IS INITIAL.
  MESSAGE 'Wrong Format' TYPE 'I'.
ELSE.
  MESSAGE 'Format OK' TYPE 'I'.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 May 2011 15:36:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899341#M1596621</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-16T15:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Validate Email by regular Expression... Need Help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899342#M1596622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this might just work for you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: str1 TYPE string,&lt;/P&gt;&lt;P&gt;      email TYPE string,&lt;/P&gt;&lt;P&gt;      first_part TYPE string,&lt;/P&gt;&lt;P&gt;      second_part TYPE string,&lt;/P&gt;&lt;P&gt;      str2 TYPE string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;str1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890._%-@'.&lt;/P&gt;&lt;P&gt;str2 = 'APP.COM.COM'.&lt;/P&gt;&lt;P&gt;email = 'FIRST_NAME.LAST_NAME at your.domain'.&lt;/P&gt;&lt;P&gt;SPLIT email AT '@' INTO first_part second_part.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;  WRITE:/ email, 'has invalid Email format'.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;  IF first_part CO str1.&lt;/P&gt;&lt;P&gt;    IF second_part CS str2.&lt;/P&gt;&lt;P&gt;      WRITE:/ email, 'has invalid Email format'.&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;      WRITE:/ email, 'has VALID Email format'.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;    WRITE:/ email, 'has invalid Email format'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 May 2011 15:39:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899342#M1596622</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-16T15:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Validate Email by regular Expression... Need Help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899343#M1596623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can find many examples for regex email validation( please search for pattern  &lt;STRONG&gt;cl_abap_regex cl_abap_matcher email&lt;/STRONG&gt; in SCN . Other than that you can also use function SX_INTERNET_ADDRESS_TO_NORMAL).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPE-POOLS:sx.


DATA:ls_input TYPE sx_address.
DATA:lv_string TYPE string.
DATA:lv_domain TYPE sx_addr.


PARAMETERS:p_mail TYPE sx_address-address.

ls_input-type = 'INT'.
ls_input-address = p_mail.

CALL FUNCTION 'SX_INTERNET_ADDRESS_TO_NORMAL'
  EXPORTING
    address_unstruct    = ls_input
    complete_address    = 'X'
  IMPORTING
    domain              = lv_domain
  EXCEPTIONS
    error_address_type  = 1
    error_address       = 2
    error_group_address = 3
    OTHERS              = 4.
IF sy-subrc ne 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
          INTO lv_string.
  MESSAGE i000(zt) WITH lv_string .
else.
  if lv_domain = 'XYZ.COM'.
    MESSAGE i000(zt) WITH 'Invalid domain' .
  endif.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 May 2011 15:51:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899343#M1596623</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-05-16T15:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Validate Email by regular Expression... Need Help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899344#M1596624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;Use Webservice to validate the email as shown below:

* Local data declaration

  DATA: lo_http_client TYPE REF TO if_http_client,
        l_string TYPE string,
        l_result TYPE string,
        l_str TYPE string,
        lt_result_tab TYPE TABLE OF string.

* Clear local variables

  CLEAR: l_string,
         l_result,
         l_str.

  REFRESH: lt_result_tab.

  CONCATENATE 'http://www.webservicex.net/ValidateEmail.asmx/IsValidEmail?Email='
              p_email INTO l_string.

* Create the HTTP Client

  CALL METHOD cl_http_client=&amp;gt;create_by_url
    EXPORTING
      url                = l_string
    IMPORTING
      client             = lo_http_client
    EXCEPTIONS
      argument_not_found = 1
      plugin_not_active  = 2
      internal_error     = 3
      OTHERS             = 4.

* Try to send data

  CALL METHOD lo_http_client-&amp;gt;send
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2.

* Try to receive data

  CALL METHOD lo_http_client-&amp;gt;receive
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3.

* Get result

  l_result = lo_http_client-&amp;gt;response-&amp;gt;get_cdata( ).
  SPLIT l_result AT cl_abap_char_utilities=&amp;gt;cr_lf INTO TABLE lt_result_tab .

* Check for validity

  READ TABLE lt_result_tab INTO l_str INDEX 2.
  IF sy-subrc = 0.
    IF l_str+44(1) &amp;lt;&amp;gt; 't'.                         "Check if True/Valid

* Raise message, Invalid Email Address

      MESSAGE e208(00) WITH text-e02.
      STOP.
    ENDIF.
  ELSE.

* Raise message, Invalid Email Address

    MESSAGE e208(00) WITH text-e02.
    STOP.
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 May 2011 18:09:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899344#M1596624</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-16T18:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Validate Email by regular Expression... Need Help</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899345#M1596625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Sebastian, Pratik &amp;amp; Keshav for the replies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SX_INTERNET_ADDRESS_TO_NORMAL doesn't validate a wrong email ID. It only splits the internet address into mail &amp;amp; domain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prathik, &lt;/P&gt;&lt;P&gt;just .com.com is not the point, Bad input could be .net.ent or .net.com or so.... &lt;/P&gt;&lt;P&gt;Amol, Thanks, but I keep receiving Error, not found in the 41 line response I get &lt;/P&gt;&lt;P&gt;I think we need to check not line 2 but line 28.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Taking cue from Prathik, I'm planning to put this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*** ls_inputmail-mail is the email-id entered by user.

************ Check for Valid Regular Expression
*****   DOT(.) is allowed more than once,
*****   @ is allowed only once,
*****   , is not allowed.


** If @ is present, more than once. Error out
    find ALL OCCURRENCES OF '@' in ls_input_mail-mail
    MATCH COUNT v_count.
    if v_count &amp;gt; 1.
      v_badpattern = 1.
    endif.

** If , is present, once, Error out
    find ALL OCCURRENCES OF ',' in ls_input_mail-mail
    MATCH COUNT v_count.
    if v_count &amp;gt; 0.
      v_badpattern = v_badpattern + 1.
    endif.
    
**   Find if domain part i.e., after @ has errors.
    SPLIT ls_input_mail-mail at '@' into v_mailpart v_domain.
*    there's a dot in the domain.
    if v_domain Co '.' .
*     last 2 char can only be country name, not anything else. 
      SPLIT v_domain at '@' into v_domain1 v_domain2.
*      v_domain2 can only be a country name, else error out
  select single landx from t005 into v_country
    where landx = v_domain2.
    if sy-subrc &amp;lt;&amp;gt; 0.
      v_badpattern = v_badpattern + 1.
    endif.  
    ENDIF.  
    
    FIND REGEX c_mailpattern IN ls_input_mail-mail IGNORING CASE .

    IF sy-subrc &amp;lt;&amp;gt; 0 OR v_badpattern &amp;gt; 0.
Write:/ ls_inputmail-mail, 'has invalid email format'.
  ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I was wondering, if there was a way to  use escapae characters &amp;amp; make the beow string as a valid regex variable to check email id.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
[a-z0-9!#$%&amp;amp;'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nevertheless, Thanks Friends for all your inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Mallikarjuna J on May 17, 2011 2:23 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2011 08:51:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/validate-email-by-regular-expression-need-help/m-p/7899345#M1596625</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-17T08:51:13Z</dc:date>
    </item>
  </channel>
</rss>

