Welcome to WebmasterWorld Guest from 54.145.208.64

Forum Moderators: ocean10000

Message Too Old, No Replies

Regex problems

Don't think i'm using Matches correctly

   
10:42 am on Jul 23, 2004 (gmt 0)

10+ Year Member



Hi all, I'm trying to use regex to take the contents of the title tag from a html page but cant get rid of the <title> tags on either side my code looks like this:

Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.Pattern = "<title>(.*)</title>"

Set Matches = regEx.Execute(strPage)
strTitle = Matches.Item(0).Value

----

It returns something like "<title>Best widgets</title>" and I want "Best widgets". I've seen examples with $1 in to return certain bits but am not sure how to use them outside of the replace method - can anyone help me out?

Thanks

Tom

11:45 am on Jul 23, 2004 (gmt 0)

10+ Year Member



Tom,

Use this function to remove all html from a string

Function RemoveHTML( strText )
Dim RegEx

Set RegEx = New RegExp

RegEx.Pattern = "<[^>]*>"
RegEx.Global = True

RemoveHTML = RegEx.Replace(strText, "")
End Function

11:16 am on Jul 25, 2004 (gmt 0)

10+ Year Member



That works great thanks :)