我有这个 ABAP 代码通过正则表达式查找文本:
DATA: regex TYPE REF TO cl_abap_regex,
match TYPE REF TO cl_abap_matcher,
match_result_tab TYPE match_result_tab.
TRY.
CREATE OBJECT regex
EXPORTING
pattern = '01|012345'.
CATCH cx_sy_regex .
ENDTRY.
TRY.
CREATE OBJECT match
EXPORTING
regex = regex
text = '0123456'.
CATCH cx_sy_matcher.
ENDTRY.
CALL METHOD match->find_all
RECEIVING
matches = match_result_tab.
它找到“01”(但我希望找到“012345”)。
DATA: offset TYPE i, length TYPE i.
FIND REGEX '01|012345' IN '0123456'
MATCH OFFSET offset
MATCH LENGTH length.
它发现012345
如我所料。
有人可以解释为什么结果不同。