2011 Dec 22 7:49 PM
Hi Experts,
I am using FIND Command to search for a string in fields of internal table.
Example:
Search string : test
Code
Loop at itab into wa.
wa = 'test record found or not '.
find all occurrences of 'test' in wa. (This gives me correct result)
but in scenario like this:
wa = 'testing is in progress'
find all occurrences of 'test' in wa.
it gives me a sy-subrc 0 as word 'test' is found in word 'testing'.
i would like to ignore this record for further processing.
Any suggestions on what should i do to search for the exact keword in the string ?
Thanks
Bhanu
2011 Dec 22 8:24 PM
Here is the sample code tested and found working:
data:
a type string,
r TYPE string VALUE '(^|[[:blank:][:cntrl:][:punct:]])test([[:blank:][:cntrl:][:punct:]]|$)',
result_tab type match_result_tab.
FIND ALL OCCURRENCES OF REGEX r IN
'test.asaa. testin atest bu;lll test111.test' RESULTS result_tab.
2011 Dec 22 8:24 PM
Here is the sample code tested and found working:
data:
a type string,
r TYPE string VALUE '(^|[[:blank:][:cntrl:][:punct:]])test([[:blank:][:cntrl:][:punct:]]|$)',
result_tab type match_result_tab.
FIND ALL OCCURRENCES OF REGEX r IN
'test.asaa. testin atest bu;lll test111.test' RESULTS result_tab.
2011 Dec 22 8:49 PM
Hi J@Y ,
It works fine for me thanks for looking into it.
One question how did you found out the string (^|[[:blank:][:cntrl:][:punct:]])
2011 Dec 22 8:58 PM