remove string
Moderators: chulett, rschirm, roy
remove string
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.
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.
Re: remove string
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'
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'
See option 3 above. Use an external filter stage. with filter command and arguments set as above.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
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
Think what smithasri is getting at is that "3374" could be anything. Try something like 's/<ContractRoleIdPK>.*</ContractRoleIdPK>//g' ... do arcanaran wrote: cat filename1.xml || sed -e 's/<ContractRoleIdPK>3374</ContractRoleIdPK>//g' > filename2.xml
Code: Select all
man sed
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
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.
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.
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
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, '')
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, '')
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: