regex/HTMLText question
Peter Brigham MD
pmbrig at gmail.com
Tue Dec 15 17:42:50 EST 2009
Ah, you want to exclude parts of words. Try this:
function wordOffsets str,cntr,wholeWords
if wholeWords = empty then put true into wholeWords
-- or you could default to false if you want
put offsets(str, cntr) into charList
-- assumes you have the offsets() function to draw on
-- see my previous email
if charList = "0" then return "0"
put the number of items of charList into nbr
put "" into oList
repeat for each item n in charList
if wholeWords and word n of cntr <> str then next repeat
put the number of words of (char 1 to n of ctr) & "," after oList
end repeat
if char -1 of oList = "," then delete char -1 of oList
return oList
end wordOffsets
This will still be extremely fast unless you're processing megabytes
of text.
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig
On Dec 15, 2009, at 5:27 PM, Chris Sheffield wrote:
> 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