remove string

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

smithasri
Participant
Posts: 23
Joined: Wed Sep 09, 2009 2:27 pm

remove string

Post by smithasri »

Dear friends,

I want remove the repeatable whole string from a line

Example: remove string <ContractRoleIdPK>3374</ContractRoleIdPK> from a line etc.

</TCRMContractPartyRoleBObj><TCRMContractPartyRoleBObj><ContractRoleIdPK>3374</ContractRoleIdPK><PartyId>403287</PartyId><RoleType>100035</RoleType><RoleValue>EMPLOYER</RoleValue><StartDate>2009-11-05 14:26:29.000000</StartDate></TCRMContractPartyRoleBObj><TCRMContractPartyRoleBObj><ContractRoleIdPK>3495</ContractRoleIdPK><PartyId>6094</PartyId><RoleType>100036</RoleType><RoleValue>LOCATION</RoleValue><StartDat
e>2009-11-05 14:26:29.000000</StartDate></TCRMContractPartyRoleBObj><TCRMContractPartyRoleBObj><ContractRoleIdPK>3683</ContractRoleIdPK><PartyId>2205</PartyId>

Please help on this issue.
rcanaran
Premium Member
Premium Member
Posts: 64
Joined: Wed Jun 14, 2006 3:51 pm
Location: CANADA

Re: remove string

Post by rcanaran »

I can think of 3 options :
1) use a server job and perform an ereplace on the derived string -- this could be a standalone job,.. if this is not practical and you are running mainly parallel jobs then

2) write a C++ routine that does the equivalent of an ereplace and use that routine in your parallel transformer derivation

3) use an external filter stage and send it to a unix for processing :
command=sed
Argument= -e 's/<ContractRoleIdPK>3374</ContractRoleIdPK>//g'
smithasri
Participant
Posts: 23
Joined: Wed Sep 09, 2009 2:27 pm

Post by smithasri »

Thanks rcanaran,

ContractRoleIdPK string repeatable in line with value. I need to delete all <ContractRoleIdPK> values </ContractRoleIdPK> values.

Please give me command in unx
rcanaran
Premium Member
Premium Member
Posts: 64
Joined: Wed Jun 14, 2006 3:51 pm
Location: CANADA

Post by rcanaran »

smithasri wrote:Thanks rcanaran,

ContractRoleIdPK string repeatable in line with value. I need to delete all <ContractRoleIdPK> values </ContractRoleIdPK> values.

Please give me command in unx
See option 3 above. Use an external filter stage. with filter command and arguments set as above.
If you want to process separately in Unix, the command is sed and the arguments are as above but in addition you will need to pipe the output like

cat filename1.xml || sed -e 's/<ContractRoleIdPK>3374</ContractRoleIdPK>//g' > filename2.xml
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

rcanaran wrote: cat filename1.xml || sed -e 's/<ContractRoleIdPK>3374</ContractRoleIdPK>//g' > filename2.xml
Think what smithasri is getting at is that "3374" could be anything. Try something like 's/<ContractRoleIdPK>.*</ContractRoleIdPK>//g' ... do a

Code: Select all

 man sed 
and check what its wildcard options are
smithasri
Participant
Posts: 23
Joined: Wed Sep 09, 2009 2:27 pm

Post by smithasri »

thanks kryton,
yes ..your right. I want same way, I tried through sed commands, but I don't have luck. Please help on this issue.

thanks for every one.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Moderator: please move to parallel forum
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There's an easy solution for either server or parallel jobs involving a mix of Left(), Index() and Right() functions - you can pass the string that is to be removed as a job parameter.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can use sed.

Alternatively you can use XML transformer to drop the unwanted values and prepare with the rest.
smithasri
Participant
Posts: 23
Joined: Wed Sep 09, 2009 2:27 pm

Post by smithasri »

Thanks Srinivasan,

My string was repeating in a single line.I can't use xml transform. Please guide me.
smithasri
Participant
Posts: 23
Joined: Wed Sep 09, 2009 2:27 pm

Post by smithasri »

Thanks Ray,

Your solution fit for only string in line. But my scenario was little bit diff, string was repeating more than 200 times in a line.

Thanks


Posted: Mon Nov 09, 2009 8:05 pm

--------------------------------------------------------------------------------

There's an easy solution for either server or parallel jobs involving a mix of Left(), Index() and Right() functions - you can pass the string that is to be removed as a job parameter.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Since you are in server edition, you can use commands like following

Note - these are something from the top of my head. So you can even do them in simple method that this.

tempString1 = EReplace(yourString, tagStartPattern, '|~')
tempString2 = EReplace(tempString1, tagEndPattern, '|')
tempString3 = Convert(tempString2, '|', @VM)
tempString4 = Fields(tempString3, '~', 1)
tempString5 = Convert(tempString4, @VM, '')
smithasri
Participant
Posts: 23
Joined: Wed Sep 09, 2009 2:27 pm

Post by smithasri »

Sorry srinivasan,

I am working on parallel edition 8.x on unix. How to change the server forum to parallel forum.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You can't, so don't worry about it. There's a PX version of EReplace posted here which a search should turn up.
-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 »

Repetition was not mentioned in the original question, which is what I answered.
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