[ABAP] RegEx – String auf Datum testen

* http://www.regular-expressions.info/dates.html
DATA: lv_in TYPE string VALUE '2016-02-01'.

* mm-dd-yyyy, mm/dd/yyyy, mm.dd.yyyy, mm dd yyyy
* '^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20|21)\d\d$'

* dd-mm-yyyy, dd/mm/yyyy, dd.mm.yyyy, dd mm yyyy
* '^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$'

* yyyy-mm-dd, yyyy/mm/dd, yyyy.mm.dd, yyyy mm dd
* '^(19|20|21)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$'
DATA(matcher) = cl_abap_matcher=>create( pattern = '^(19|20|21)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$'
                                         text = lv_in
                                         ignore_case = abap_true ).

IF matcher->match( ) = abap_true.
  WRITE: / lv_in.
ENDIF.