Re: eregi help for <body...></body>
| From: | Toby Butzon | Date: | Fri, 08 Dec 2000 00:55:36 +0000 |
| Subject: | Re: eregi help for <body...></body> | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-29254@lists.php.net to get a copy of this message | ||
By using (.*), you're matching anything from 0 to any number of times. It's
not going to stop until it gets to the end of the string, even if you wanted
it to match the closing slant bracket (>) after that pattern. You have to
specify exactly what it's allowed to match before it breaks and starts the
next pattern (set of parens). Try this:
function inStringSub($string) {
ereg("(<body[_\L='\".#\L
0-9a-zA-Z-]*>)(.*)(</body>)",$string,$result);
return($result[2]);
}
You might want to keep this handy as a reference:
http://www.thunderstone.com/doc/rexlong.html
Good luck!
Toby Butzon
[ criticism spurs improvement ]
----- Original Message -----
From: "Jeremy Simon" <jeremy@safessl.com>
To: <php-general@lists.php.net>
Sent: Thursday, December 07, 2000 7:00 PM
Subject: [PHP] eregi help for <body...></body>
: I need some help with with trying to eregi a file for the <body
: bgcolor="#000000"> to the </body>.
:
:
: My basic code will search for the <body> tag to the </body> tag and return
: it. The problem is that I don't have just a simple <body> tag I have a
<body
: bgcolor="#000000" text="#FFFFFF">. I need a way to have it search for the
: "<body" to the first ">" then go the (.*)</body>.
:
:
: <--Begin Paste --->
:
:
: function inStringSub($string) {
: eregi("<body(.*)</body>",$string,$result);
: return($result[1]);
:
: }
:
: <---End Paste --->
:
:
: --
: PHP General Mailing List (http://www.php.net/)
: To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
: For additional commands, e-mail: php-general-help@lists.php.net
: To contact the list administrators, e-mail: php-list-admin@lists.php.net
:
: