how to replace special characters with N in a string

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
develop
Premium Member
Premium Member
Posts: 7
Joined: Fri May 26, 2006 4:34 pm

how to replace special characters with N in a string

Post 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



:)
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Do you have a finite set of special characters?

Give example
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

u can use Ereplace() , Convert() or Change() functions for more help u can go through online manual
hi sam here
clickart
Premium Member
Premium Member
Posts: 15
Joined: Tue Oct 18, 2005 10:14 pm
Location: Schaumburg, IL

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

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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..
Last edited by chulett on Thu Oct 26, 2006 5:42 pm, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
talk2shaanc
Charter Member
Charter Member
Posts: 199
Joined: Tue Jan 18, 2005 2:50 am
Location: India

Post 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"
Shantanu Choudhary
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:idea: Syntax for Convert() is identical in server, BASIC and parallel Transformer stages.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Excellent... then my answer stands. Ditch the commas. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
clickart
Premium Member
Premium Member
Posts: 15
Joined: Tue Oct 18, 2005 10:14 pm
Location: Schaumburg, IL

Post by clickart »

Chulett,
I ran a test job without the commas and it worked fine. :!:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply