As I have been writing to Chris of list, I have been trying to use the
RegExp object.

Yes it is a powerfull litle bugger, and
Yes the tricky bit is to get the expression right.

So far I haven't been able to get it absoulutely right

Below is my previous attempts to do this

Function Highlight(sString,sHighlight)
        ' Regular Expression Object (Requires vbScript 5.0 and above)
        Dim regEx, strippedHTLM
        
        ' If no content was received, exit the function
        If sString                      = "" Then Exit Function 
        
        ' Create Regular Expression object
        Set regEx                       = New RegExp
        
        ' Keep finding links after the first one.

        regEx.Global            = True
        
        ' Ignore upper/lower case
        regEx.IgnoreCase        = True
        
        
        'Strip off all HTML tags
        'regEx.Pattern          = "<(.|\n)+?>"
        'strippedHTLM           = regEx.Replace(sString,"")
                
        ' Look for Highligts
        'regEx.Pattern          ="^([^<]|[^<\/])[^\w^\.^\s^=^""]*^>|(" &
sHiglight & ")$" 
        regEx.Pattern           ="([^<]|^)(" & sHighlight & ")([^>]|$)"
        'regEx.Pattern          ="(<\/?[^>]+?>.*?)(" & sHiglight &
")(.*?<\/?[^>]+?>)"
        'regEx.Pattern          ="(<(.*)>.*)(" & sHiglight & ")(<\/\1>|$)"
        'regEx.Pattern          ="(>)([\.\w\d\s\/\=\""\%]*)(" & sHighlight &
")([\.\w\d\s\/\=\""\%]*)(<)$"
        'regEx.Pattern          ="(>)(.*)(" & sHighlight & ")(.*)(<)$"
        
        'Highligt context
        'Temporaraly disabled due to errors in replacing inside HTML tags
        'Highlight                      = regEx.Replace(sString, "$1<span
class=""highlight"">$2</span>$3")
        Highlight                       = regEx.Replace(sString, "$1$2$3")
        
End Function

As you can see, I have tried a lot of options, but I haven't got i right so
far

<Thomas/>


> -----Original Message-----
> From: Dave DeVaux [mailto:[EMAIL PROTECTED]] 
> Sent: 21. august 2002 00:16
> To: ActiveServerPages
> Subject: RE: Google Highlight
> 
> 
> You can use regular expressions to get this to work; you'll 
> want to read up
> on the RegExp object.   You can then define your regular 
> expression in such
> a way that you "ignore" text within <> characters.  Also, 
> make sure you
> consider case-sensitivity (should you also highlight 
> "Image"?).  The RegExp
> object has a property called IgnoreCase to deal with this.
> 
> And, what if "image" is found within another word?  For 
> example, should
> "primage" match? (Yes, this is a word).
> 
> Anyway, the tricky bit is getting your regular expression 
> right.  Once you
> do that, you can just use the Replace property of the RegExp object.
> 
> -Dave
> 
> 

---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to