Search / replace

Jim Bufalini jim at
Sat Feb 20 08:53:47 EST 2010

Jacque wrote:

> This sounds like a perfect job for the replacetext command...
> ...there's a way to do that but I'm not sure how.
> At any rate, once you get the right regex figured out, it's a one-liner
> to do what you want.

Glen, while Jacque works on a regex and after getting some sleep, ;-) here
is the correct way to do what you want in a "readable" Rev loop (replace
*FieldName* with the name of your actual field and put this code into a

on mouseUp pMouseBtnNo
    put replaceChar("[", the text of fld "FieldName") into fld "FieldName"
end mouseUp
function replaceChar pCharToReplace, pString
    local tOffset
        put offset(pCharToReplace,pString) into tOffset
        if tOffset = 0 then exit repeat
        if char (tOffset - 1) of pString is an integer then
            put "_" into char tOffset of pString 
            put empty into char tOffset of pString 
        end if
    end repeat
    return pString
end replaceChar

Aloha from Hawaii,

Jim Bufalini

More information about the Use-livecode mailing list