What function to use for replacing 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
blazDelParis
Participant
Posts: 19
Joined: Wed Sep 08, 2010 6:47 am

What function to use for replacing string?

Post by blazDelParis »

on a UNIX machine, with PX server (v8.01)

For example, in a field i get filePaths.
but the slashes are twins ex : "C:\\toto\\toto1\\toto2\\toto3"

in a transformerStage (on a parallel job); how can I simply replace the double slash into a simple slash like : "C:\toto\toto1\toto2\toto3"

in a transformer stage (on parallel job) , Ereplace(), change() and pxEreplace() don't work as the compiler do not recognize these functions.
For internal reasons, I can't use an external routine.
left() and right() use is not a simple solution as the number of double-slash may change.
Convert() can't work either as it replaces only one character with another only one character.

Of course there is very badly ugly solution.
In a transformer stage, I set 25 stages variables using Field() function with "\" as separator and 1 to 25 as number of occurences.
Then I can concatenate the 25 stage variables if there are not empty.

But if there is more than 13 doubles slashes (and it can happen), I'll miss a part of the filePath.

Have you got an idea ?
Last edited by blazDelParis on Wed Feb 09, 2011 9:17 am, edited 2 times in total.
it's good to give a fish to a hungry man
it's better to teach him fishing
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Split from this topic. I had to guess on the particulars (version, O/S) so if either are wrong please edit your post and correct them.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Search DSXchange for source code for pxEreplace() - it does not ship with DataStage so you have to create a parallel routine of it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
blazDelParis
Participant
Posts: 19
Joined: Wed Sep 08, 2010 6:47 am

Post by blazDelParis »

thank you for your answer.
my boss doesn't like me using routines for some security reasons he says.
So I would rather like not using it but if it is the only way...
it's a pity there is not such a basic function shipped with datastage.

So i guess, I'll get the same problem for regular expressions.

If someone doesn't want to search here is the links to the good routines :

pxEreplace() :
http://66.34.129.47/viewtopic.php?t=138 ... 1b9c56fd6f

matching a regular expression :
http://66.34.129.47/viewtopic.php?t=107 ... 1b9c56fd6f

thanks to the authors of these routines
it's good to give a fish to a hungry man
it's better to teach him fishing
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There IS a BASIC function (Ereplace()). But you can only use BASIC functions in the BASIC Transformer stage in parallel jobs.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply