2010 Feb 03 5:08 AM
Dear Experts,
I need to extract a particular word from my string,
Ex : O/10/01/025 / DEMO CAR
I want to extract the word DEMO..How to do that..?
Dear Experts,
I need to extract a particular word from my string,
Ex : O/10/01/025 / DEMO CAR
I want to extract the word DEMO..How to do that..?
2010 Feb 03 5:16 AM
DATA: lv_string TYPE string value 'O/10/01/025 / DEMO CAR' ,
lv_string2 TYPE string value 'DEMO' .
IF lv_string CS lv_string2.
...
ENDIF.
2010 Feb 03 5:19 AM
Hi,
1.First Find the the Position using the SEARCh command.You will get SY-FDPOS value.
2.You length of the string.
3.Access the field like field1+sy-fdpos(lengthofword).
Thanks & Regards,
Vamsi.
2010 Feb 03 5:26 AM
Hi,
Also it depends on what you want to do with it. If you want to remove the word completely you could try:
REPLACE FIRST OCCURRENCE OF 'DEMO' with ''.
Or if you want the offset value (the position of the substring) you can use:
DATA: l_offset type i.
FIND FIRST OCCURRENCE OF 'DEMO' MATCH OFFSET l_offset.
Cheers
Alex
Edited by: Alex Cook on Feb 3, 2010 6:31 AM
2010 Feb 03 5:34 AM
arthi,
please explain your exact need. you know the word or position or want to search a word or a particukar length of word or you want to find the word in the string??
2010 Feb 03 7:44 AM
Hi,
please check below statments.
DATA: text TYPE STRING.
text = 'Everyone knows this'.
FIND 'know' IN text.
even you can use SEARCH statment.
DATA F(20) VALUE 'Peter Paul Mary'.
SEARCH F FOR '*UL' AND MARK.
SY-SUBRC is now set to 0, since the search string was found in 'Paul'. SY-FDPOS has the value 6, since the character string found starts at the offset 6. Also, the search string is marked, so that the new contents of F are as follows:
'Peter PAUL Mary'
Thanks,
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |