Welcome to WebmasterWorld Guest from

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?




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

10+ Year Member


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 :)

Featured Threads

Hot Threads This Week

Hot Threads This Month