Page 1 of 1

how to replace special characters with N in a string

Posted: Thu Oct 26, 2006 3:54 pm
by develop
hi all
i have a string in which there are some special characters ,those need to be replace with N
any help would be greatly appreciated



:)

Posted: Thu Oct 26, 2006 3:58 pm
by narasimha
Do you have a finite set of special characters?

Give example

Posted: Thu Oct 26, 2006 4:07 pm
by samsuf2002
u can use Ereplace() , Convert() or Change() functions for more help u can go through online manual

Re: how to replace special characters with N in a string

Posted: Thu Oct 26, 2006 4:42 pm
by clickart
You can use the Convert function in a Transformer stage.

Syntax:
convert('From List','To List','Expression')

In From List, you can specify the list of special characters that needs to be replaced
In To List, you can specify the list of new characters that will replace the special chars. In your case it will 'N'.
In Expression, you can give the column name.

e.g
Convert('$,@,!,%,#','N,N,N,N,N', DSLink3.SPEC_CHAR)

Note:
This method is good if you have a small set of special characters to be replaced. Else the 'From List' will be too long.

Posted: Thu Oct 26, 2006 5:39 pm
by chulett
The correct syntax for Convert would actually be:

Code: Select all

Convert('$@!%#','NNNNN', DSLink3.SPEC_CHAR)
No commas... unless you want those replaced as well... with another comma. :wink:

I'd still like to see examples of these 'special characters' before people go too crazy with the suggestions...

Edited to add: Ack, am I in the PX forum? Dang. That's technically a Server answer so the PX syntax may very well require commas. If that's the case, my bad..

Posted: Thu Oct 26, 2006 5:39 pm
by talk2shaanc
unfortunately, you dont have luxory of some of the function of server job in Datastage EE... the best option you have in PX job is use "convert"

Posted: Thu Oct 26, 2006 10:41 pm
by ray.wurlod
:idea: Syntax for Convert() is identical in server, BASIC and parallel Transformer stages.

Posted: Fri Oct 27, 2006 12:11 am
by chulett
Excellent... then my answer stands. Ditch the commas. :wink:

Posted: Fri Oct 27, 2006 5:07 am
by clickart
Chulett,
I ran a test job without the commas and it worked fine. :!:

Posted: Fri Oct 27, 2006 8:06 am
by chulett
:!: Because, as I noted, you are telling it to replace all commas in the string with yet another comma, so it just looks like it works fine. Check the examples in the online help.

It's certainly not a fatal problem, just wastes cycles. It's not all that different from telling it to replace all 'X' characters with an 'X'.