on ‎2020 Aug 10 5:13 AM
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.
Request clarification before answering.
Try something like this:
If Right({Header.Address}, 1) = chrw(13) then
left({Header.Address}, len({Header.Address}) - 1
else
{Header.Address}-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually, if you're dealing with Windows text, the end of line is two characters - CR/LF (carriage return, line feed) In that case, you can change the formula to this:
If Right({Header.Address}, 2) = (chrw(13) + chrw(10)) then
left({Header.Address}, len({Header.Address})) - 2
else
{Header.Address}
Hey dell.stinnett-christy ,
Still no luck with this code, i modified it to check the condition and to give me a "Yes" or "No" answer whether a chrw(13) or (10) was picked up but it only ever returned "No" regardless of which number i used for the character.
This is weird considering if i use the replace function in my original post, it does actually replace all of them, including the one between state and postcode i am trying to target...
I even made a formula to give me right({Header.Address},6) which returned a blank character, i then made another formula to give me the ASCII code for the returned character and it was 13..
Now when i went to check IF right({Header.Address},6) was = chr(13) it came back "No"
I dont know why this is proving so difficult.
Regards,
Nick
Let's try something different...
StrReverse(Replace(Replace(StrReverse({Header.Address}), chr(10), "", 1, 1), chr(13), "", 1, 1))This will reverse the string so that the last characters are now the first. Then it will replace the first occurrence of chr(10) and chr(13) with blanks, then it will reverse the string back to its original order.
-Dell
That worked! Thanks so much Dell, ive been scratching my head over this for a while now. I tried applying this logic but couldnt get the code right myself.
Regards,
Nick
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.