Search and Replace

Dan Friedman dan at
Tue Oct 15 23:03:00 EDT 2002


Both of these items are correct.  But still doesn't exit the repeat.  Here's
what I have:

function replaceGender whatText
  local tStart,tEnd
  put "he,him,himself,his,he's,boy,guy" into SearchWordsMale
  put "she,her,herself,her,she's,girl,gal" into SearchWordsFemale
  set the wholeMatches to true
  repeat forever
    if it is true then
      put char tStart to tEnd of tText into tFoundChunk
      put (charToNum(toUpper(char 1 of tFoundChunk)) = charToNum(char 1 of
tFoundChunk)) into isUpper
      put itemOffset(tFoundChunk,SearchWordsMale) into tItem
      if tItem <> 0 then
        put item tItem of SearchWordsFemale into temp
        if isUpper then put toUpper(char 1 of temp) into char 1 of temp
        put temp into char tStart to tEnd of whatText
        -- you decide... bail? error out? ignore?
      end if
      exit repeat
    end if
  end repeat
  return whatText
end replaceGender

> Dan,
> Two things to check:
> 1) Check the script to make sure the "local tStart,tEnd" is in there; if it
> isn't, Rev won't actually put anything in tStart or tEnd since they weren't
> "localed".
> 2) Check to make sure in the matchchunk it says:
>   (boy|h(e|im|is|imself|e's)|guy)
> between the two [^A-Za-z0-9] and not:
>   boy|h(e|im|is|imself|e's)|guy
> ... without the parentheses around it, there will be nothing to return as a
> match.
> Let me know if it still doesn't work...
> Don't worry about not getting matchChunk and matchText... I've got a
> mini-tutorial in the works on regEx in Rev/MC that I hope to have released
> as soon as I get another chunk of time to complete it... ;-)
> Ken Ray
> Sons of Thunder Software
> Email: kray at
> Web Site:

More information about the use-livecode mailing list