1. w32replaceItem misbehaving
- Posted by marky1124 Jan 22, 2009
- 994 views
Hi,
The documentation for w32replaceItem says
- w32replaceItem (sequence pList, object pOld, object pNew)
- Replaces all occurances of pOld with pNew
- Note this routine will not do recursive replacements. That is, if pNew contains pOld, it doesn't go into a never-ending loop.
Whilst it's true that it doesn't go into a never-ending loop, it does do additional text replacements if pNew contains pOld. Which I believe it shouldn't do.
Here's an example
include win32lib.ew sequence email email = "mark_young@mydomain.com" email = w32replaceItem(email, "@", "@@") puts(1, email))
This produces the result
mark_young@@@@@@@@@@@@mydomain.com
Am I correct that this is wrong? Am I missing a simple way to turn a single @ into two?
Cheers,
Mark
2. Re: w32replaceItem misbehaving
- Posted by marky1124 Jan 22, 2009
- 994 views
I should just add that I wrote a replacement w32replaceItem for myself...
function my_w32replaceItem(sequence pText, sequence pOLD, sequence pNEW) sequence lParts, lText lParts = w32split(pText, pOLD) lText = "" for x = 1 to length(lParts)-1 do lText &= lParts[x] & pNEW end for lText &= lParts[length(lParts)] return lText end function
Cheers
Mark
3. Re: w32replaceItem misbehaving
- Posted by CChris Jan 22, 2009
- 1064 views
It is wrong, and the docs are right.
In the w32replaceItem() code, change the line
lFrom += lLenNew
by
lFrom = lPos + lLenNew
This has been there for a while. I'll update on SF, and perhaps make a corrective release before going to vacations.
hris
4. Re: w32replaceItem misbehaving
- Posted by marky1124 Jan 23, 2009
- 1002 views
Thanks very much CChris
5. Re: w32replaceItem misbehaving
- Posted by marky1124 Jan 23, 2009
- 1059 views
CChris said...
hris
BTW - Was this a subtle w32replaceItems related joke