Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:34:49+00:00 2026-06-09T20:34:49+00:00

I’m trying to scrape an HTML page for it’s title using a regular expression.

  • 0

I’m trying to scrape an HTML page for it’s title using a regular expression. Here’s what I’m trying:

\<title\>\A\Z\</title\>

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:34:51+00:00Added an answer on June 9, 2026 at 8:34 pm
    <title>(.*?)</title>
    

    The brackets around .*? lets you reference the capture group. Your regular expression library will probably have a way to return what is matched in capture groups. The group indexed 0 is the whole match. So you should probably pick group index 1, which is the first starting bracket it comes across (there’s only one set of brackets here).

    In some libraries, you need:

    .*?<title>(.*?)</title>.*
    

    because some require a complete match of the string.

    • \A is used to match the start of a string container
    • \< is used to match the boundary between whitespace and a character
    • \> matches the boundary between a character and whitespace

    Be aware that this is not foolproof. Webpages can break your regular expression with pages like:

    <html>
        <script>
          // <title>HAHA YOU GOT THE WRONG TITLE</title>
        </script>
        <title>The Actual title</title>
      </head><body></body>
    </html>
    

    You can avoid the possibility of this by making your regex more complicated before matching the title. However, that doesn’t really work. Because the fake title could be in an HTML comment <!-- <title></title> -->, or a /* javascript */ comment.

    Thus, it is better to use an actual HTML parser. You can search google to find many of these.

    • If you are using Ruby, you can use the nokogiri gem – http://nokogiri.org/.

    • For Java – http://htmlparser.sourceforge.net/.

    • For python – http://docs.python.org/library/htmlparser.html.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.