Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Get substring after a certain pattern

Former Member
0 Likes
1,323

Hello,

I have a long string of characters (plain HTML codes in one long line) and would like to obtain a substring after a pattern. For example, part of the long string looks like this:

...abcdefg123456789...

I would like to obtain "123456789" from this long line. And I am certain the previous substring, i.e. abcdefg, is unique in this long string line.

How do I go about achieving this with ABAP code?

Thanks!

Edited by: Jay Yang on Aug 4, 2009 1:06 PM

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
910

Try to use class CL_CRM_HTML_PARSER and use method PARSE_HTML_STRING

a®

4 REPLIES 4
Read only

former_member194669
Active Contributor
0 Likes
911

Try to use class CL_CRM_HTML_PARSER and use method PARSE_HTML_STRING

a®

Read only

0 Likes
910

Thanks a@s. That's a great hint! However, when I tried with method parse_html_string by passing in the long html string I have, it didn't get me the result properly. I located the part/tag I wanted from the returned part table (a SPAN tag), but the attribute simply listed the SPAN id, instead of the value between SPAN and /SPAN. Could you provide me with further hint?

Thanks again!

Read only

0 Likes
910

As per earlier reply you mentioned abcdefg is unique

then try something simple


report zars
  no standard page heading line-size 255.

data : ser type string value 'testing1234abcdefg123456789'.
data : pos type i.

search ser for 'abcdefg'.
pos = sy-fdpos + 7.
write ser+pos(9).

Will it do ?

a®

Read only

0 Likes
910

YES! That does the trick! Thanks!