• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1775
  • Last Modified:

regular expression to match title tag on html page

Hi all,

Can somebody write me a regular expression to match the contents of the title tag on an html page?

Thanks
0
zattz
Asked:
zattz
  • 3
  • 2
1 Solution
 
ddrudikCommented:
<title>.*?</title>
0
 
zattzAuthor Commented:
That returns the tag & contents ie "<title>blah</title>"

I only want "blah" returned.
0
 
b0lsc0ttIT ManagerCommented:
zattz,

You can do this with ....

      resultString = Regex.Match(subjectString, "<title>([^<]*)</title>").Groups[1].Value;

Let me know if you have any questions or need more information.

b0lsc0tt
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ddrudikCommented:
zattz, sorry, I misunderstood your initial requirement, consider this instead:
(?<=<title>).*?(?=</title>)
0
 
zattzAuthor Commented:
Thanks ddrudik, yours works 100%
0
 
ddrudikCommented:
Thanks for the question and the points.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now