面向对象的正则表达式
对于更高级的正则表达式操作,最好使用 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