another way to match this that works with preg or ereg is to go like
this:
<body[^>]*>

On Mon, 25 Jun 2001 15:31:29 -0400, scott [gts]
([EMAIL PROTECTED]) wrote:
>exactly.  use the non-greedy "?" with the perl regex's
>to have perl match the least amount of characters it can.
>
>preg_match('/<blah(.*?)>/', $text, $matches)
>
>in the case of perl regexp's, you have to specifically
>tell the regexp not to be greedy.  the "?" regexp modifier
>is how you do this.  (otherwise, the regexp will try and
>match the maximum amount of text that it can, which
>usually isnt what you want, since it'll match *eveything*
>between "blah" and the last occurance of ">" in the text)
>
>so, in the case of this text:
><blah now>
>sasfd asdf asdf
></html>
>
>the greedy will match something like this:
> now>
>sasfd asdf asdf
></html>
>
>and the non-greedy will match something like this:
>now
>
>
>
>
>
>> -----Original Message-----
>> From: Richard Lynch [mailto:[EMAIL PROTECTED]]
>> Subject: Re: [PHP] Help with simple regular expression
>>
>>
>> That's because POSIX is greedy.  Or Perl is greedy.  Whatever.
>>
>> When one of them does that, use the other one.
>>
>> Instead of eregi, use pregi.
>>
>> Disclaimer:  What I know about Regex could fit in a matchbook.
>>
>> --
>> WARNING [EMAIL PROTECTED] address is an endangered species -- Use
>> [EMAIL PROTECTED]
>> Wanna help me out?  Like Music?  Buy a CD: http://l-i-
>>e.com/artists.htm
>> Volunteer a little time: http://chatmusic.com/volunteer.htm
>> ----- Original Message -----
>> From: "Aral Balkan" <[EMAIL PROTECTED]>
>> Newsgroups: php.general
>> Sent: Sunday, June 24, 2001 7:34 PM
>> Subject: [PHP] Help with simple regular expression
>>
>>
>> > Hi all,
>> >
>> > I'm trying to match the body tag in an HTML file (eg. <body
>> > bgcolor="ffffgg">) with the following regular expression and
>>eregi:
>> >
>> > <body.*>
>> >
>> > Unfortunately it matches everything from the body tag onwards
>>and doesn't
>> > stop at the greater-than sign. It should be simple thing but I'm
>>stumped!
>> To
>> > me the regex reads match string that begins with <body followed
>>by zero or
>> > more of anything and ending with a greater-than sign.
>> >
>> > Any help would be greatly appreciated! :)
>> >
>> > Aral
>> > ______________________________
>> > ([EMAIL PROTECTED])
>> >     New Media Producer, Kismia, Inc.
>> > ([EMAIL PROTECTED])
>> >     Adj. Prof., American University
>> > ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
>> >
>> >
>> >
>> > --
>> > 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: php-list-
>>[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: php-list-
>>[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: php-list-
>[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]

Reply via email to