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
[email protected]
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, [email protected] 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
[email protected]
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
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to