‎2009 Jun 29 10:24 AM
Hi, Experts.
I'd like to use 'FIND' and 'REGEX' for seaching certain records in an internal table.
The Search condition is this. 'NN-'. Starts with 'N' and then the string has '-N'.
I used 'FIND' like this. 'IFND regex 'N*\Q-N\E' in dobj.
But, I couldn't get a result that I want. This Returns some garbages that it didn't start with 'N' and include '-N'.
What should I use REGEX to solve this Problem.
The following string is example.
'New-Notepad'.
Thanks.
‎2009 Jun 29 10:37 AM
‎2009 Jun 29 10:33 AM
Hi,
The below regex will solve your problem.
FIND REGEX 'N\C*-N' IN dobj.
IF sy-subrc = 0.
"Match found
ELSE.
"NO Match Found
ENDIF.Check and revert back.
Regards
Karthik D
‎2009 Jun 29 10:37 AM
‎2009 Jun 29 10:41 AM
I think what you have used is right!
Please refer the below codes for more details....You only have to add the matching offset and matching length addition...
DATA: lv_string TYPE string.
DATA: moff TYPE i,
mlen TYPE i.
lv_string = 'Newotepad-N'.
FIND REGEX 'N*-N*' IN lv_string MATCH OFFSET moff
MATCH LENGTH mlen.
WRITE:/ moff,
mlen.
It gave me the output as offset '9' and length '2'....which is right...
Try and let me know...