hiliting all instances of a string in a field
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. -- Trevor DeVore Blue Mango Multimedia [EMAIL PROTECTED] ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: hiliting all instances of a string in a field
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. Dar Scott ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: hiliting all instances of a string in a field
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 [EMAIL PROTECTED] ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: hiliting all instances of a string in a field
On Wednesday, March 3, 2004, at 11:05 AM, Trevor DeVore wrote: 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? Or skip said elements or chars before matching string. Use a non-gathering group and (because of the bug) a range on the repeat. I know that is cryptic and short. Ask if I need to elaborate. Dar ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: hiliting all instances of a string in a field
On Mar 3, 2004, at 11:27 AM, Dar Scott wrote: On Wednesday, March 3, 2004, at 11:05 AM, Trevor DeVore wrote: 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? Or skip said elements or chars before matching string. Use a non-gathering group and (because of the bug) a range on the repeat. I know that is cryptic and short. Ask if I need to elaborate. Please elaborate :-) -- Trevor DeVore Blue Mango Multimedia [EMAIL PROTECTED] ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: hiliting all instances of a string in a field
On Wednesday, March 3, 2004, at 11:35 AM, Trevor DeVore wrote: Or skip said elements or chars before matching string. Use a non-gathering group and (because of the bug) a range on the repeat. I know that is cryptic and short. Ask if I need to elaborate. Please elaborate :-) I gotta run and will be back in maybe three hours. This is wrong, wrong but might get you started if you want to play with it: \A(?:a.*\\a|.){0,100}(abc)(.*)\z where abc is your match and there are no more than 100 characters or a elements between instances. When the bug is fixed change {0,100} to *. Remember to test for match and nonmatch. Dar Scott ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: hiliting all instances of a string in a field
On Wednesday, March 3, 2004, at 06:05 PM, [EMAIL PROTECTED] 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. Trevor, Is this the kind of thing you want to do? http://news.lycos.com/news/ story.asp?section=ElectionsstoryId=829253topic=bush That was pretty easy to do: 1. Remove all and / from the topic string (the topic string is the string you're wanting to hilite) 2. split the html you're wanting to hilite using the topic string. Unfortunately you can't use Transcript's split command because it only splits on a character, but you can use offset to simulate a string split. 3. as you step through each found topic string, look for the next and next characters. Call the offset of the character nextOpen, and the offset of the character nextClose. 4. Check whether to hilite or not: If nextClose nextOpen then ' we're in the middle of a tag, so don't hilite it else 'we're not in a tag, so hilite the topic string 'do this by replacing the topic string you've found with this ' span class= quote hiliterCssName quote topicStr /span end if 5. You can find the css value for hiliterCssName by looking in the css file for the above referenced page. Best, -- Frank ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: hiliting all instances of a string in a field
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. Trevor, as usual, I forgot to read the subject. You can get the text not the htmlText and go through that. Check the text properties of each one back in the field to see if it is a link. Do the highlighting thing (whatever you want), if it is not. (If you don't have access to the original field, use a temporary or hidden field.) Dar doing-it-the-hard-way Scott ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: hiliting all instances of a string in a field
On Mar 3, 2004, at 3:05 PM, Dar Scott wrote: You can get the text not the htmlText and go through that. Check the text properties of each one back in the field to see if it is a link. Do the highlighting thing (whatever you want), if it is not. (If you don't have access to the original field, use a temporary or hidden field.) Duh, I forgot I could set the backgroundColor of the text in the field without having to worry about the htmlText. This is what I came up with: put text of tTargetField into tText put number of chars of pHiliteTerm - 1 into tLength put 0 into tLastOffset put offset (pHiliteTerm, tText, tLastOffset) into tOffset repeat while tOffset 0 set backgroundColor of char (tLastOffset + tOffset) to (tLastOffset + tOffset + tLength) of tTargetField to yellow put tLastOffset + tOffset into tLastOffset put offset (pHiliteTerm, tText, tLastOffset) into tOffset end repeat Thanks, -- Trevor DeVore Blue Mango Multimedia [EMAIL PROTECTED] ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: hiliting all instances of a string in a field
On Mar 3, 2004, at 2:48 PM, Frank Leahy wrote: Trevor, Is this the kind of thing you want to do? http://news.lycos.com/news/story.asp? section=ElectionsstoryId=829253topic=bush That is what I was trying to accomplish. As I mention in my other post I ended up using offset, backgroundColor and the text property of the field to accomplish this. Thanks, -- Trevor DeVore Blue Mango Multimedia [EMAIL PROTECTED] ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
Re: hiliting all instances of a string in a field
On Wednesday, March 3, 2004, at 04:44 PM, Trevor DeVore wrote: Duh, I forgot I could set the backgroundColor of the text in the field without having to worry about the htmlText. This example does not check that it is in a link. Maybe that is straightforward to add, maybe with a compromise and checking only that the linkText of the first character is empty. Dar Scott ___ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution