当前位置:网站首页>Parse the value of uuid using ABAP regular expressions

Parse the value of uuid using ABAP regular expressions

2022-08-10 15:32:00 Wang Zixi

What the following code does is,使用 ABAP 正则表达式,将 uuid = The following specific values ​​are parsed out:

在这里插入图片描述

REPORT z.

data: lv type string value 'uuid=dd&sid=0.7795630486081988'.

DATA: moff TYPE i,
      mlen TYPE i.

FIND REGEX '^uuid=(.*)&.*$' IN lv
     MATCH OFFSET moff
     MATCH LENGTH mlen.

WRITE: / sy-subrc.

WRITE:/ moff, mlen.

WRITE:/ lv+moff(mlen).

DATA(reg_pattern) = '^uuid=(.*)&.*$'.

DATA(lo_regex) = NEW cl_abap_regex( pattern = reg_pattern ).

DATA(lo_matcher) = lo_regex->create_matcher( EXPORTING text = lv ).

CHECK lo_matcher->match( ) = abap_true.

DATA(lt_reg_match_result) = lo_matcher->find_all( ).

READ TABLE lt_reg_match_result ASSIGNING FIELD-SYMBOL(<reg_entry>) INDEX 1.

data(match) = lt_reg_match_result[ 1 ].

data(submatch) = match-submatches[ 1 ].

WRITE:/ 'uuid:', lv+submatch-offset(submatch-length).
原网站

版权声明
本文为[Wang Zixi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208101459029138.html