ABAP通过正则表达式提成字符串中的数字例子

前端之家收集整理的这篇文章主要介绍了ABAP通过正则表达式提成字符串中的数字例子前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
下面程序的场景是如何从字符串 'Log Attributes 0.5( 0 ) ( 43.56 % Available )'提取数字,并输出

Report zz_test.
data : lv_str type string value 'Log Attributes 0.5 ( 0) ( 43.56 % Available )'.
data : lv_str_tmp type string.
data : lv_num1 type string,
lv_num2 type string,lv_num3 type string. data : lv_len type i. data: result_tab type match_result_tab. data : wa_result like line of result_tab. lv_str_tmp = lv_str. find all occurrences of regex '(\s\d+.\d*)' in lv_str_tmp resultsresult_tab. loop at result_tab into wa_result from 1 to 3. case sy-tabix. when 1. lv_num1 =lv_str_tmp+wa_result-offset(wa_result-length). write:lv_num1. when 2. lv_num2 =lv_str_tmp+wa_result-offset(wa_result-length). write:lv_num2. when 3. lv_num3 =lv_str_tmp+wa_result-offset(wa_result-length). write:lv_num3. endcase. endloop.

猜你在找的正则表达式相关文章