Search and Replace

Ken Ray kray at sonsothunder.com
Tue Oct 15 23:33:01 EDT 2002


Sorry, Dan, it looks like a typo. This line:

>       put char tStart to tEnd of tText into tFoundChunk


should read:

>       put char tStart to tEnd of whatText into tFoundChunk

Then everything should work OK. Sorry about that...

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/

----- Original Message -----
From: "Dan Friedman" <dan at clearvisiontech.com>
To: <use-revolution at lists.runrev.com>
Sent: Tuesday, October 15, 2002 10:45 PM
Subject: Search and Replace


> Ken,
>
> 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
>     get
>
matchChunk(whatText,"[^A-Za-z0-9](boy|h(e|im|is|imself|e's)|guy)[^A-Za-z0-9]
> ",tStart,tEnd)
>     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
>       else
>         -- you decide... bail? error out? ignore?
>       end if
>     else
>       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 sonsothunder.com
> > Web Site: http://www.sonsothunder.com/
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list