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

find Substring

Former Member
0 Likes
1,002

Hi all,

I want to find substring from main string .

Separator exists in my substring.

eg: 'AA$BB$cc$DD'

I want AA BB CC DD sepatared.

9 REPLIES 9
Read only

Former Member
0 Likes
965

Hi.. Use split statement

SPLIT f AT g INTO h1 ... hn.

Read only

Former Member
0 Likes
965

Hi,

split mainstring at '$' into it_tab.

concatenate it_tab1 it_tab2 into substring separated by space.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Feb 14, 2008 2:18 PM

Read only

Former Member
0 Likes
965

Syntax

SPLIT dobj AT sep INTO

{ {result1 result2 ...} | {TABLE result_tab} }

[IN {BYTE|CHARACTER} MODE].

You can write as

SPLIT total_string AT '$' INTO temp1 temp2 temp3 temp4 IN CHARECTER MODE.

SPLIT total_string AT '$' INTO TABLE result-tab IN CHARECTER MODE.

Edited by: Minal Nampalliwar on Feb 14, 2008 10:45 AM

Read only

Former Member
0 Likes
965

Hi,

You can use the SPLIT command, like

SPLIT v_str AT v_separator INTO p1 p2 p3 ....

or ... INTO TABLE t_str.

Best regards,

Ivson

Read only

Former Member
0 Likes
965

SPLIT

Splits a string.

Syntax

SPLIT <c> AT <del> INTO <c1>... <cn> INTO TABLE <itab>

[IN BYTE MODE|IN CHARACTER MODE].

This statement searches the character field <c> for delimiter strings <del> and the parts before and after the delimiters are placed in the target fields <c1> ...> … <cn>, or into a new line of the internal table <itab>. In Unicode programs, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions.

<REMOVED BY MODERATOR>

REGARDS

PRIYA.

Edited by: Alvaro Tejada Galindo on Feb 14, 2008 2:19 PM

Read only

Former Member
0 Likes
965

Use,

data: str1 type string,

s1 type sring,

s2 type string,

s3 type sring,

s4 type string.

str1 = 'AA$BB$CC$DD'.

split str1 at '$' into s1 s2 s3 s4.

now s1 = AA,s2 = BB,s3 = CC,s4 = DD

Read only

Former Member
0 Likes
965

Split <str_name> at <delemeter($$)> into <var1> <var2> <var3> ...... (based on our source string)

Read only

Former Member
0 Likes
965

Hi,

try this code as i had similar requirement

data : itab type string occurs 0 with header line.

split v_spell_string at space into table itab.

clear v_spell_string.

loop at itab .

if itab <> 'Rupees'.

concatenate v_spell_string itab into v_spell_string separated by ' '.

endif.

endloop.

else you can also use kewords : REPLACE ALL OCCURANCE OF ......

FOR EXAMPLE if u jst want to remove the seperator or replace with something then

: REPLACE ALL OCCURRENCES OF 'Rupees' in v_spell_string with 'and'.

else you can use SPLIT AT Cammand.

example : split str1 at <seperator> into str2........strn

(this can be used if u are sure that there are going to be fix number of words in a string, else use first option

Edited by: Naseer uddin on Aug 30, 2008 9:35 AM

Read only

Former Member
0 Likes
965

hi,

U can use SPLIT.

For Eg-

split str at $ into str1,str2, str3.

hope this helps u.

Regards,

Aleem