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 .
Replace
Moderators: chulett, rschirm, roy
Substring using the "[]" operators:
Where "XXXX" is the replacement text for string positions 10 thru 12.
Edited because you actually meant 10th thru 12th.
Code: Select all
YourString[1,9]:"XXXX":YourString[13,999]
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
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Hi Ray,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 ...
Could you please let me know how to use with Ereplace since there will be multiple occurrence in the string .
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
... only with the internal looping feature in version 8.5, since there are multiple occurrences.chulett wrote:Quite simple to substring instead, as already suggested.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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.
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
"You can never have too many knives" -- Logan Nine Fingers