Replace

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
saj
Participant
Posts: 30
Joined: Fri Aug 28, 2009 6:00 am

Replace

Post by saj »

Hi ,
I have a requirement for replacing a substr strting from 10th to 13th.
Ex:
Ad12345678301ATI

I need to replace the value starting from 10th position to 13th
In the above case 301 with 812.
please help .
Is it possible to do this with Ereplace .
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Substring using the "[]" operators:

Code: Select all

YourString[1,9]:"XXXX":YourString[13,999]
Where "XXXX" is the replacement text for string positions 10 thru 12.

Edited because you actually meant 10th thru 12th. :?
Last edited by chulett on Wed Feb 09, 2011 6:07 pm, edited 1 time in total.
-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 »

It is easily possible to do this with Ereplace() if that's the only occurrence of 301 in the data, otherwise you'd have to do some more manipulation to determine which occurrence of 301 to replace. Replacing the substring is likely to be a lot easier.

Code: Select all

InLink.TheString[1,9] : "801" : InLink.TheString[13,999999]
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
saj
Participant
Posts: 30
Joined: Fri Aug 28, 2009 6:00 am

Post by saj »

ray.wurlod wrote:It is easily possible to do this with Ereplace() if that's the only occurrence of 301 in the data, otherwise you'd have to do some more manipulation to determine which occurrence of 301 to replace. R ...
Hi Ray,
Could you please let me know how to use with Ereplace since there will be multiple occurrence in the string .
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Quite simple to substring instead, as already suggested.
-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 »

chulett wrote:Quite simple to substring instead, as already suggested.
... only with the internal looping feature in version 8.5, since there are multiple occurrences.

To use pxEreplace() - assuming you've installed and compiled it, etc. -

Code: Select all

pxEreplace(InLink.TheString, "301", "801", -1, 0)
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 »

I was responding to the original question, specifically - replacing the contents of positions 10 thru 12 in the string. One time, one place, hence the suggestion to substring. The OP was wondering how to make the pxEreplace do the same because there can be multiple occurances of the target characters in the string, something you've now answered. Sorta.

However, "301" was (I assume) just one example and (again) I've been assuming the actual need was not for a fixed value but rather regardless of the actual value.
-craig

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