11-29-2019 3:25 AM
Dear Experts,
I have a string as follow
Data(v_string) = '12345***678**9'
I need to get the position of * after the number 8.
I cannot used:
FIND FIRST OCCURRENCE OF '*' in v_string match OFFSET pos
because it only return the position of the first * appearance which is the one after number 5.
I cannot use
SEARCH ... STARTING AT.... because it doesn't recognize *.
So is there away to do this?
Thanks
11-29-2019 5:40 AM
Then FIND ALL OCCURRENCES?
DATA(v_string) = '12345***678**9'.
DATA(_regex) = '[^\*]\*'.
FIND ALL OCCURRENCES OF REGEX _regex IN v_string RESULTS DATA(sub).
11-29-2019 3:41 AM
Hi,
First find the position of occurrence of the number(in your example 8). Then try fetching the next character using string offset.
Thanks.
11-29-2019 3:59 AM
but the occurrence number is random not always eight,
even the length is also dynamic, it can be 1 to 100 but with two parts that consist of ****
11-29-2019 4:57 AM
try some thing like below
DATA : lv_str TYPE string VALUE '123**34**',
lv_offset TYPE i,
lv_var1 TYPE string,
lv_var2 TYPE string.
"now here i need to find the offset of * which is after 4
"sine i already know i need to find the occurence of * afetr 4 i will first devide it to two halfes and in second half i will seacrh *
SPLIT lv_str AT '4' INTO lv_var1 lv_var2.
FIND FIRST OCCURRENCE OF '*' IN lv_var2 MATCH OFFSET lv_offset.
11-29-2019 4:42 AM
Hi Samuel Indrajaya Try with REGEX, it can be achievable with REGEX, refer to below blogs on how to use REGEX, refer to demo program DEMO_REGEX_TOY
11-29-2019 5:40 AM
Then FIND ALL OCCURRENCES?
DATA(v_string) = '12345***678**9'.
DATA(_regex) = '[^\*]\*'.
FIND ALL OCCURRENCES OF REGEX _regex IN v_string RESULTS DATA(sub).
11-29-2019 2:53 PM