-4

source code

HTML = "<title>RUU</title>"
reExtraTitle = re.compile("<title[^>]*>([^<]*)</title>", re.IGNORECASE)
mcTitle = reExtraTitle.match(HTML)
if mcTitle:
    print mcTitle.group()
else:
    print "no Title"

Regular expressions help me

1 Answers1

4

Welcome to StackOverflow. People are hard-handed with the downvotes today, I'm sorry about that. I'm guessing you're not a native english speaker, correct?

Your question fulfills the SSCCE principle, though it shows you're a bit light on the research, and you didn't actually ask a proper question, though it's evident what you're after. Your answer lies in the re module doc, which you should have read.

You need to import re first, and then change

print mcTitle.group()

to

print mcTitle.group(1)

As others have hinted, you should perhaps consider using a dedicated html parser instead of using regexp.

Community
  • 1
  • 1
Lauritz V. Thaulow
  • 49,139
  • 12
  • 73
  • 92