Posted By

qrist0ph on 11/17/09


Tagged

regexp abap


Versions (?)

ABAP Regexp


 / Published in: Other
 

  1. REPORT ZCA_PROGRAM2.
  2.  
  3. SELECTION-SCREEN BEGIN OF SCREEN 100 AS WINDOW.
  4. PARAMETERS email TYPE c LENGTH 30 LOWER CASE.
  5. SELECTION-SCREEN END OF SCREEN 100.
  6.  
  7. CLASS demo DEFINITION.
  8. PUBLIC SECTION.
  9. CLASS-METHODS main.
  10. ENDCLASS.
  11.  
  12. CLASS demo IMPLEMENTATION.
  13. METHOD main.
  14. DATA: regex TYPE REF TO cl_abap_regex,
  15. matcher TYPE REF TO cl_abap_matcher.
  16.  
  17. CREATE OBJECT regex EXPORTING pattern ='\w+(\.\w+)*@(\w+\.)+(\w{2,4})' ignore_case = 'X'.
  18. DO.
  19. CALL SELECTION-SCREEN 100 STARTING AT 10 10.
  20.  
  21. matcher = regex->create_matcher( text = email ).
  22. IF matcher->match( ) IS INITIAL.
  23. MESSAGE 'wrong format' TYPE 'S' DISPLAY LIKE 'E' .
  24. ELSE.
  25. MESSAGE 'Format ok' TYPE 'S'.
  26. EXIT.
  27. ENDIF.
  28. ENDDO.
  29. ENDMETHOD.
  30. ENDCLASS.
  31. START-OF-SELECTION.
  32. demo=>main( ).

Report this snippet  

You need to login to post a comment.