cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Remove last carriage return from address string

lsauser
Participant
0 Likes
1,717

Hi all,

I have an address block like such;

123 Fake St
Suburb, VIC
4512

I want to only remove the last carriage return so it looks like;

123 Fake St
Suburb VIC 4512

I know i can use the following to get rid of all the carriage returns which does put it all on one line and i have played around with this with no luck getting it right. I have a feeling i need to use a combination of instr, strreverse and right but havent been able to get the logic to work.

replace({Header.Address},chrw(13),'')

As always, any help is greatly appreciated.

View Entire Topic
former_member308222
Active Participant
0 Likes

Hi,

Please try with below code but condition is you know the last some characters from data.

With using below coding I differentiate on two parts, part 1 is for left side all data and part 2 is for replace chr(13) to ' ').

Part 1

left ("123 Fake St" & chr(13) & "Suburb, VIC" & chr(13) & "4512",len("123 Fake St" & chr(13) & "Suburb, VIC" & chr(13) & "4512")-5 )

Part 2

Replace ("123 Fake St" & chr(13) & "Suburb, VIC" & chr(13) & "4512",chr(13), ' ', len("123 Fake St" & chr(13) & "Suburb, VIC" & chr(13) & "4512")-4)

Whole query

left ("123 Fake St" & chr(13) & "Suburb, VIC" & chr(13) & "4512",len("123 Fake St" & chr(13) & "Suburb, VIC" & chr(13) & "4512")-5 ) & Replace ("123 Fake St" & chr(13) & "Suburb, VIC" & chr(13) & "4512",chr(13), ' ', len("123 Fake St" & chr(13) & "Suburb, VIC" & chr(13) & "4512")-4)

If any further query please inform.

- Rajkumar Mane

lsauser
Participant
0 Likes

Thanks for your input rajkumar.mane,

Wont this only work with that example address i provided?

Regards,

Nick