1. An idea that worked

Dear Euphorians

Below is an idea that worked. You may have no need for it
but it was fun getting it to work. It implements a find/replace
but goes about it differently ... at least differently to the
way I've been coding such things over the years.

Use it if you want. Poke holes in it if you will. Improve on it
if you can (which is likely) but give me some feedback.

Thanks,

ZB.
------------------- replace.e -----------------------

global function replace( sequence inThis, sequence findThis, sequence putThis )
    sequence res
    integer i
    res = ""
    while 1 do
        i = match( findThis, inThis )
        if i = 0 then
           res &= inThis
           exit
        end if
        res &= inThis[ 1 .. i - 1 ]
        res &= putThis
        inThis = inThis[ i + length( findThis ) .. length( inThis ) ]
    end while
    return res
end function

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu