regex/HTMLText question
zryip theSlug
zryip.theslug at gmail.com
Tue Dec 15 18:58:47 EST 2009
Hi Chris,
As said by Jim Ault, I think that you have first to decide the list of whole
word forms you accept.
"space&use&space";"use&comma","use&dot"
=> " use ","use,","use.",".use",".use."...
Once your list prepared, substitute your word by a key that you will replace
at the fly by a word to search.
=> " <w> ","<w>,","<w>.",".<w>",".<w>."...
Then in a loop treats the different cases with the solution of Craig Newman
likes this:
repeat with aWord in wordList
repeat with aRegex in regexList
put replaceText(aRegex,"<w>",aWord) into wholeWordForm -- replace
the "<w>" key in your pattern by the word that you need
get fld "yourField"
replace wholeWordForm with "<box>" & wholeWordForm & "</box>" in it
end repeat
end repeat
set the htmltext of fld "yourField" to it
This is a first approach because it encloses the word with its possible
punctuation.
-Zryip TheSlug- wish you the best ! 8)
2009/12/15 Chris Sheffield <cmsheffield at gmail.com>
> Thanks, Craig. Unfortunately, this doesn't quite work either. If I were to
> run:
>
> replace "use" with "<box>use</box" in it
>
> It would not only replace the whole word "use", but also the string "use"
> in the word "used", so I would end up with something like "<box>use</box>d",
> which is not the desired result.
>
>
> On Dec 15, 2009, at 1:56 PM, DunbarX at aol.com wrote:
>
> > Right, thanks to all.
> >
> > Chris', your original regex question could better be addressed by:
> >
> > on mouseup
> > get fld "yourField"
> > replace yourtext with "<box>" & yourtext & "</box>" in it
> > set the htmltext of fld "yourField" to it
> > end mouseup
> >
> > This would be fast, and easily extendable, since we are just crunching
> > data.
> >
> > Not that there isn't a good regex solution as well...
> >
> > Craig Newman
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-revolution
>
> --
> Chris Sheffield
> Read Naturally, Inc.
> www.readnaturally.com
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list