Page 1 of 2

remove string

Posted: Mon Nov 09, 2009 3:51 pm
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.

Re: remove string

Posted: Mon Nov 09, 2009 4:14 pm
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'

Posted: Mon Nov 09, 2009 4:40 pm
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

Posted: Mon Nov 09, 2009 4:44 pm
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

Posted: Mon Nov 09, 2009 6:56 pm
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

Posted: Mon Nov 09, 2009 7:58 pm
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.

Posted: Mon Nov 09, 2009 8:03 pm
by ray.wurlod
Moderator: please move to parallel forum

Posted: Mon Nov 09, 2009 8:05 pm
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.

Posted: Tue Nov 10, 2009 3:49 am
by Sainath.Srinivasan
You can use sed.

Alternatively you can use XML transformer to drop the unwanted values and prepare with the rest.

Posted: Tue Nov 10, 2009 7:41 am
by smithasri
Thanks Srinivasan,

My string was repeating in a single line.I can't use xml transform. Please guide me.

Posted: Tue Nov 10, 2009 7:46 am
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.

Posted: Tue Nov 10, 2009 8:04 am
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, '')

Posted: Tue Nov 10, 2009 8:12 am
by smithasri
Sorry srinivasan,

I am working on parallel edition 8.x on unix. How to change the server forum to parallel forum.

Posted: Tue Nov 10, 2009 8:38 am
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.

Posted: Tue Nov 10, 2009 1:23 pm
by ray.wurlod
Repetition was not mentioned in the original question, which is what I answered.