Page 1 of 1

Convert double character into single

Posted: Mon Sep 30, 2013 5:34 pm
by dsquest
Hello,

This might have been discussed already. But I couldn't find anything close to my need.

I have the following.

Code: Select all

"|||abc|||def|hg"
I wanted it to be converted into

Code: Select all

"abc|def|hg"
I think I can remove the leading and trailing Pipes using Trim with 'B".

I have remove the duplicate intermediate pipes and replace into one.
FYI: Covert('||','|',input) isn't working.

Posted: Mon Sep 30, 2013 8:32 pm
by ray.wurlod
If there are no space characters in your data (as per your example) you could convert the pipe characters to space characters, use a simple Trim() function (only one argument), then convert the space characters back to pipe characters.

Code: Select all

Convert(" ", "|", Trim(Convert("|",  " ",  InLink.TheString)))

Posted: Tue Oct 01, 2013 1:54 am
by ArndW

Code: Select all

TRIM("|||abc|||def|hg","|","R")
will do what you want.

Posted: Tue Oct 01, 2013 3:42 am
by chandra.shekhar@tcs.com
Ray, I must say that your solution is fantastic. :D

Posted: Tue Oct 01, 2013 4:13 am
by priyadarshikunal
Ray,

Why do we need two converts, I believe trim with R should do the work. also suggested by Arnd.

Posted: Tue Oct 01, 2013 10:09 am
by dsquest
Thanks AndrW! It worked!.

Posted: Tue Oct 01, 2013 4:27 pm
by ray.wurlod
I'd forgotten the "R" option for Trim(). It's not an option I use very often.