2008 Mar 28 3:16 AM
Hi,
I need to search a word instead of string from another string.
I tried below code and expected that FIND will not search 'weeds' but it seems FIND ignores trailing spaces of string zstr and thus finds word 'weeds'.
***********************************************************
DATA: zstr type string value 'we ',
lv_string type string value 'These are weeds',
result_tab TYPE match_result_tab.
FIND FIRST OCCURRENCE OF regex zstr IN lv_string
IGNORING CASE
RESULTS result_tab.
**********************************************************
Please consider that zstr is runtime variable with no fixed length.
If anybody has the solution, reply back fast !
Regards,
Sourabh
Hi,
I need to search a word instead of string from another string.
I tried below code and expected that FIND will not search 'weeds' but it seems FIND ignores trailing spaces of string zstr and thus finds word 'weeds'.
***********************************************************
DATA: zstr type string value 'we ',
lv_string type string value 'These are weeds',
result_tab TYPE match_result_tab.
FIND FIRST OCCURRENCE OF regex zstr IN lv_string
IGNORING CASE
RESULTS result_tab.
**********************************************************
Please consider that zstr is runtime variable with no fixed length.
If anybody has the solution, reply back fast !
Regards,
Sourabh
2008 Mar 28 3:26 AM
hi,
Check out in this way ...
if lv_string cp zstr.
write : 'Success'.
else.
write : 'Failed'.
endif.
2008 Mar 28 3:33 AM
Hi,
Hi,
DATA STRING(30) VALUE 'This is a little sentence.'.
WRITE: / 'Searched', 'SY-SUBRC', 'SY-FDPOS'.
ULINE /1(26).
SEARCH STRING FOR 'X'.
WRITE: / 'X', SY-SUBRC UNDER 'SY-SUBRC',
SY-FDPOS UNDER 'SY-FDPOS'
SEARCH STRING FOR 'itt '.
WRITE: / 'itt ', SY-SUBRC UNDER 'SY-SUBRC',
SY-FDPOS UNDER 'SY-FDPOS'
SEARCH STRING FOR '.e .'.
WRITE: / '.e .', SY-SUBRC UNDER 'SY-SUBRC',
SY-FDPOS UNDER 'SY-FDPOS'.
SEARCH STRING FOR '*e'.
WRITE: / '*e ', SY-SUBRC UNDER 'SY-SUBRC',
SY-FDPOS UNDER 'SY-FDPOS'.
SEARCH STRING FOR 's*'.
WRITE: / 's* ', SY-SUBRC UNDER 'SY-SUBRC',
SY-FDPOS UNDER 'SY-FDPOS'.
Hope it will solve your problem..
Pls. reward if useful...
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |