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

processing string-- still having problem

Former Member
0 Likes
1,016

Hi,

i need to remove all spaces in a string immediately after ',' but not all .

for eg :

name = first, middle last

after processing it should appear as

first,middle last.

replace ', ' with ',' into name ...doesn't seems to be working. is there any way to do that in a single statement.

your help would be appreciated.

Thanks,

Kranthi.

Message was edited by: kranthi kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
926

Condense is not working...but i need to remove spaces Immediately after ','

Thanks,

Kranthi.

Message was edited by: kranthi kumar

11 REPLIES 11
Read only

Former Member
0 Likes
926

it worked for me... see below code

data : name(40).

name = 'first, middle last'.

replace ', ' with ',' into name.

write : name.

Read only

Former Member
0 Likes
926

Hi Kranthi,

try this....

REPLACE FIRST OCCURRENCE OF '' IN name WITH ','.

REPLACE FIRST OCCURRENCE OF ',,' IN name WITH ','.

reagrds

vijay

Read only

Former Member
0 Likes
926

data: l_str type string.

l_str = 'First , Middle Last'.

write:/ l_str.

replace ' , ' with ',' into l_str.

write:/ l_str.

Output:

First , Middle Last

First,Middle Last

<u>worked for me too.</u>

Read only

Former Member
0 Likes
926

Hi,

for helful answers please reward .

thanks

vijay

Read only

Former Member
0 Likes
926

Thanks all for your response.

however, if there is MORE than one SPACE after COMMA it doesn't work ,could you let me know more feasible solution

Thanks,

Kranthi.

Read only

0 Likes
926

Ok

I think You requirement will not allow you to use condense.

so i will find some thing...

vijay

Read only

0 Likes
926

use the CONDENSE command

Read only

Former Member
0 Likes
927

Condense is not working...but i need to remove spaces Immediately after ','

Thanks,

Kranthi.

Message was edited by: kranthi kumar

Read only

0 Likes
926

CONDENSE NO-GAPS will remove all spaces, but just CONDENSE will remove all but one spaces.

Read only

Former Member
0 Likes
926

data : w_str1(40),

w_str2 like name.

split name at ',' into w_str1 w_str2.

shift w_str2 left deleting leading space.

concatenate w_str1 ',' w_str2 into name.

Read only

Former Member
0 Likes
926

Hi Kranthi,

Try to use the below code.

data: test(15),

test1(10),

test2(10).

test = 'first, last'.

split test at ',' into test1 test2.

condense test2.

concatenate test1 ',' test2 into test.

write:/ test .