hiliting all instances of a string in a field
Trevor DeVore
lists at mangomultimedia.com
Wed Mar 3 13:05:09 EST 2004
On Mar 3, 2004, at 10:59 AM, Dar Scott wrote:
>
> On Wednesday, March 3, 2004, at 10:21 AM, Trevor DeVore wrote:
>
>> Has anyone written a function that will find all instances of a
>> string in the htmlText of a field EXCEPT if it appears in a tag such
>> as <a></a>? I need to hilite all instances of the string in the
>> field. I figure I'm either missing a really obvious function already
>> in Rev that will do it or I need a fancy regular expression.
>
> I assume you want the character offset.
>
> One approach would be to use a loop and a matchChunk. The match chunk
> would find the start of the match and the start of the rest. This is
> applied to rest until there is no rest (so to speak). Collect the
> offsets or process them as you find them. One problem is that this
> might run afoul of bug 16. In that case, limit yourself to a maximum
> number of elements to be ignored between each instance.
>
> If you just want to count them or something, then use replaceText() to
> remove the <a></a> and then count the string instances.
I think matchChunk is the way to go. I just need to figure out the
regular expression for it and regular expressions aren't my strong
suit. I think the regular expression would have to find the string and
then look behind for a "<a" with no "</a>" between it and the string.
Does this sound right? Anyone know how to write that?
--
Trevor DeVore
Blue Mango Multimedia
trevor at mangomultimedia.com
More information about the use-livecode
mailing list