RE: [PHP] I suck at regular expressions! -- not as bad, now

2001-11-15 Thread Richard S. Crawford



Thanks to everyone who helped me figure this out.

I foolishly didn't realize that I was using the htmlspecialchars() function 
on the string that I was pulling from the file, but not accounting for that 
in the regexp.  So, what I was getting was:

 BLAH BLAH BLAH

but what I was trying to find was:

 < title >BLAH BLAH BLAH< /title >

It's all good now.


Sliante,
Richard S. Crawford

http://www.mossroot.com
mailto:[EMAIL PROTECTED]
AIM: Buffalo2K   ICQ: 11646404  Y!: rscrawford
"It is only with the heart that we see rightly; what is essential is 
invisible to the eye."  --Antoine de Saint Exupéry

"Push the button, Max!"


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] I suck at regular expressions!

2001-11-15 Thread Brian Paulson

Been Using this Function for some time and works real well with two
exceptions

1. if the title line has a CR in it it will no get the title 
Example: This is a bad
Title

2. If there are any other < > tags in the title it will fail.

([^<]*)(.*)', $string,
$regs ) )
   {
   $string = $regs[2];
}
}  
 return $regs[1];   
}
} 
?>

-Original Message-
From: Richard S. Crawford [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, November 14, 2001 11:30 PM
To: [EMAIL PROTECTED]
Subject: [PHP] I suck at regular expressions!


I am trying to get the title of an html file... you know, the string 
between the < title > and < /title > tags...

Here is the function I've got so far:

function fileTitle($fileName) {
 $myFile = fopen($fileName, "r");
 $myText="";
 while (!feof($myFile)) {
 $myText .= fgets($myFile,255);
 }
 fclose($myFile);
 if (eregi("(.+)",$myText,$theTitle)) return 
$theTitle[0];
 else return "(No Title)";
}

The trouble is, it always returns "(No Title)", regardless of whether
the 
file has a title defined in the header or not.

I suspect I'm doing something fundamentally wrong.  Can anyone set me
straight?



Sliante,
Richard S. Crawford

http://www.mossroot.com
mailto:[EMAIL PROTECTED]
AIM: Buffalo2K   ICQ: 11646404  Y!: rscrawford
"It is only with the heart that we see rightly; what is essential is 
invisible to the eye."  --Antoine de Saint Exupéry

"Push the button, Max!"


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]