on 09-03-2021 9:32 AM
My requirement is to read 4 digit number in below String by using REGEX and I am able to read 1925 but I am also getting 2017 and 0001 and I want to avoid 0001 because total string is not 4 digit.
String : /DEV/NAN DE RANCE SA 1925 DU 15.11.2017 TR0478989117T0001 INBOUND MONEY TRANSFER
Below code for your reference
DO ls_len TIMES.
CLEAR:ls_num.
ls_off = sy-index - 1.
ls_num = gs_data-payadd_info.
REPLACE REGEX '^(\d+).*$' IN SECTION OFFSET ls_off OF ls_num WITH '$1'.
IF sy-subrc = 0.
REPLACE REGEX '^.*[^\d](\d*)$' IN ls_num WITH '$1'.
lv_length = strlen( ls_num ).
IF lv_length = '4'.
FIND FIRST OCCURRENCE OF ls_num IN gs_data-payadd_info RESULTS ls_end_pos.
lv_length = ls_end_pos-offset - lv_start_pos.
EXIT.
ENDIF.
ENDIF.
ENDDO.
User | Count |
---|---|
88 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.