lopband
asked on
regex to get content between title tags
Hello,
Basically, I am doing a fget() to get a remote page, then i need a regex (which i cant figure) to read the text between
<title> .. and </title>
for example:
<title> I am a fancy title </title>
running the regex should give me:
I am a fancy title
Thanks!
Basically, I am doing a fget() to get a remote page, then i need a regex (which i cant figure) to read the text between
<title> .. and </title>
for example:
<title> I am a fancy title </title>
running the regex should give me:
I am a fancy title
Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello,
I think you misunderstood me... I have no idea what the title will say, " I am a fancy title" was just an example.
It should work with any title...
unless thats what it already does..I have not tested your code as yet.. ;)
I think you misunderstood me... I have no idea what the title will say, " I am a fancy title" was just an example.
It should work with any title...
unless thats what it already does..I have not tested your code as yet.. ;)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
glad to help.
ASKER
Hello Heilo,
I am getting this error when i run your code:
Warning: preg_match() [function.preg-match]: Unknown modifier 't' in C:\wamp\www\ezee\tests\get _remote_ti tle.php on line 3
This is the entire code:
<?php
$data = file_get_contents("http://www.youtube.com/watch?v=oQ2dKXGAjNg");
preg_match('/#<title>([^<] *)</title> #/iU',$dat a,$match);
$title=$match[1];
echo $title;
?>
I am getting this error when i run your code:
Warning: preg_match() [function.preg-match]: Unknown modifier 't' in C:\wamp\www\ezee\tests\get
This is the entire code:
<?php
$data = file_get_contents("http://www.youtube.com/watch?v=oQ2dKXGAjNg");
preg_match('/#<title>([^<]
$title=$match[1];
echo $title;
?>
Open in new window