sap technical
matinal
原文出處:
【abap系列】sap abap常用正規表示式大全
特殊表示式 :
1.貨幣格式: '123123211312.333333'.replace(/(?=(?!^)(?:\d)+(?:\.|$))(\d(\.\d+$)?)/g, ',$1') //輸出 123,123,211,312.333333 ps:tcl 大牛推薦
另外,replace也支援regex關鍵字。
最後:只能是ecc6或者更高版本才可以(abap supports posix regular expressions as of release 7.00)
report z_test.
data: str type string ,
result_tab type match_result_tab ,
wa like line of result_tab.
*找出string裡面的雙位元組字元
str = 'abc我啊adfsf們'.
find all occurrences of regex '[^x00-xff]*' in str results result_tab.
loop at result_tab into wa.
write / str+wa-offset(wa-length).
endloop.
*找出string裡面的單位元組字元
str = 'abc我啊adfsf們'.
find all occurrences of regex '[x00-xff]*' in str results result_tab.
write / '-----'.
loop at result_tab into wa.
write / str+wa-offset(wa-length).
endloop.
*找出string裡面的ip位址
str = 'ip1:172.16.32.12 ip2:192.168.1.1 '.
find all occurrences of regex 'd+.d+.d+.d+' in str results result_tab.
write / '-----'.
loop at result_tab into wa.
write / str+wa-offset(wa-length).
endloop.
*找出string裡面的***-********格式的**號碼
str = 'ip1:172.16.32.12 021-12345678 '.
find all occurrences of regex 'd-d|d-d' in str results result_tab.
write / '-----'.
loop at result_tab into wa.
write / str+wa-offset(wa-length).
endloop.
*找出string裡面的15/18位身份證號碼
str = 'ip1:172.16.32.12 3722198003041234 '.
find all occurrences of regex 'd|d' in str results result_tab.
write / '-----'.
loop at result_tab into wa.
write / str+wa-offset(wa-length).
endloop.
***使用class的例子:
report z_barry_test.
parameters: p_input type string default 'ip1:172.16.32.12 ip2:192.168.1.1 ' obligatory.
data: regex type ref to cl_abap_regex,
matcher type ref to cl_abap_matcher,
match type c .
data: result_tab type match_result_tab ,
wa like line of result_tab.
create object regex
exporting
pattern = 'd+.d+.d+.d+'
ignore_case = 'x'.
try.
call method regex->create_matcher
exporting
text = p_input
* table =
receiving
matcher = matcher .
catch cx_sy_matcher .
endtry.
try.
call method matcher->match "是否完全匹配
receiving
success = match.
catch cx_sy_matcher .
endtry.
call method matcher->find_all
receiving
matches = result_tab.
loop at result_tab into wa.
write / p_input+wa-offset(wa-length).
endloop.
***sap給的判斷email位址的例子***
parameters email type c length 30 lower case default
ABAP系列 SAP ABAP常用正規表示式大全
sap technical matinal 原文出處 abap系列 sap abap常用正規表示式大全 特殊表示式 1.貨幣格式 123123211312.333333 replace d d d g,1 輸出 123,123,211,312.333333 ps tcl 大牛推薦 另外,replac...
SAP ABAP 的常用debug方式
sap abap 的常用debug方式 1.直接在程式中設斷點 在se38裡面打上breakpoint,程式執行到該處即進入debug模式 2.background job的debug 進入sm37 查詢到自己想要debug的後台程式,這裡執行完畢或者正在執行的均可進入debug 查詢到後打中job...
SAP ABAP 的常用debug方式
本文章已收錄於 sap abap 的常用debug方式 1.直接在程式中設斷點 在se38裡面打上breakpoint,程式執行到該處即進入debug模式 2.background job的debug 進入sm37 查詢到自己想要debug的後台程式,這裡執行完畢或者正在執行的均可進入debug 查...