物件導向的正規表示式
對於更高階的正規表示式操作,最好使用 CL_ABAP_REGEX
及其相關類。
DATA: lv_test TYPE string,
lo_regex TYPE REF TO cl_abap_regex.
lv_test = 'The quick brown fox'.
CREATE OBJECT lo_regex
EXPORTING
pattern = 'q(...)\w'.
DATA(lo_matcher) = lo_regex->create_matcher( text = lv_test ).
WRITE: / lo_matcher->find_next( ). " X
WRITE: / lo_matcher->get_submatch( 1 ). " uic
WRITE: / lo_matcher->get_offset( ). " 4