Search / replace
jim at visitrieve.com
Fri Feb 19 21:48:00 CST 2010
Glen Bojsza wrote:
> Sorry to bother everyone but either I'm tired or brain dead.
> I have a field which has hundreds of lines.
> For all [ in the field I need to check to see if the character to it's
> immediate left is a number.
> If it is a number then the [ is to be converted into an _.
> If it is not a number then the [ is to be removed (no substitution or
> I need to be able to cycle through the entire field which each line may
> contain several [.
> Any thoughts would be appreciated as I have tried using a combination
> find characters and foundchunk on the field without success.
Use the *offset()* function as in:
Local tOffset, tCharsToSkip, tFieldText
put 0 into tCharsToSkip
put fld "theFieldName" into tFieldText
put offset("[",tFieldText,tCharsToSkip) into tOffset
if tOffset = 0 then exit repeat
if char (tOffset - 1) of tFieldText is an integer then
replace char tOffset of tFieldText with "_"
put tOffset + 1 into tCharsToSkip
replace char tOffset of tFieldText with empty
put tOffset into tCharsToSkip
put tFieldText into fld "theFieldName"
Aloha from Hawaii,
More information about the use-livecode