Page 1 of 1

ereplace and fmt equivalent in parallel

Posted: Sat Jun 05, 2010 12:14 am
by Vignesh Shanmugam
Hi all,
I have requirement in which ,i need to change a alphanumeric number to 10 digit number with all the alphabets replaced to "0" including "@,&,%,/" etc and preceding zero's to make it 10 digit .

(e.g):-(1). AF001234 TO 0000001234
(2). N/A TO 0000000000
(3). 1234ERTY TO 0012340000

Can anyone give me with some ideas?

Thanks

Posted: Sat Jun 05, 2010 2:40 am
by ray.wurlod
Convert() function is perfect for this task, in both server and parallel jobs.

Posted: Sat Jun 05, 2010 5:55 am
by chulett
And then pad zeros for the parts it doesn't handle.

Posted: Sun Jun 06, 2010 12:44 pm
by ray.wurlod
It won't. For starters, there's no If in the expression, even though there are Then and Else. Second, you seem to be assuming some kind of loop through the characters in the string, which does not exist.

Set a stage variable to contain all the characters that must be converted to zero, for example svZeroChars. Create another containing the number of zero characters as there are in svZeroChars, for example svZeroes. Then use Convert() to convert these to zero and any function to pad to length. For example

Code: Select all

Right("000000000000":Convert(svZeroChars, svZeroes, InLink.TheString), 12)

Posted: Mon Jun 07, 2010 11:15 am
by Vignesh Shanmugam
I tried using "Convert" functions and "Str" .It worked fine guys.Thanks you