Search and Replace
Ken Ray
kray at sonsothunder.com
Tue Oct 15 22:48:01 EDT 2002
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/
----- Original Message -----
From: "Dan Friedman" <dan at clearvisiontech.com>
To: <use-revolution at lists.runrev.com>
Sent: Tuesday, October 15, 2002 9:58 PM
Subject: Re: Search and Replace
> Ken,
>
> I can't get [your] function to work. It never exits out of the repeat.
> Although the matchChunk does return true, the tStart and tEnd variables
are
> never being filled with anything. What am I doing wrong?
>
> (Please excuse my ignorance in regards to the matchChunk call.. I've read
> the docs about a zillion times and I still don't get matchChunk and
> matchText)
>
> Thanks!
> -Dan
>
>
> > I'm here! :-) It's a little tricky (what with the capitalization and
> > everything), but here goes:
> >
> > 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
>
> _______________________________________________
> 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