Extract title tags from normal text
- by pravin
I am working on one task, to extract title tag from given normal text ( it's not a HTML DOM ).
I have below cases where need to extract title tag(s) :
Case 1 :
<html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>
Expected :
Title of the document
Case 2 :
<html>
<head>
<title>Title of the document</title>
<title>Continuing title</title>
</head>
<body>
The content of the document......
</body>
</html>
Expected :
Title of the document Continuing title
Case 3 (Nested title tags)
<html>
<head>
<title>Title of the document
<title>Continuing title</title></title>
</head>
<body>
The content of the document......
</body>
</html>
Expected :
Title of the document Continuing title
I wanted to extract title tags using regular expression in javascript. Reg-ex should work for above case.
Is anyone knows about this..please let me know...
Thanks in Advance