In article [EMAIL PROTECTED],
[EMAIL PROTECTED] (scott [gts]) wrote:
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
Yes, Perl is greedy
I was actually using ereg which I believe is POSIX, so POSIX must be greedy
too!
Aral :)
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯
--
PHP
On Monday 25 June 2001 09:27, Richard Lynch wrote:
That's because POSIX is greedy. Or Perl is greedy. Whatever.
Perl is greedy. It *should* have worked with eregi...
body.*
Unfortunately it matches everything from the body tag onwards and
doesn't stop at the greater-than sign. It
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
[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
That's because POSIX is greedy. Or Perl is greedy. Whatever.
Perl is greedy. It *should* have worked with eregi...
body.*
Yes, Perl is greedy (there has to be some kind of default behaviour)!
BUT it is SO easy to make it decent:
/body.*?/
that's it!!!
michi
--
GMX - Die
(eg. body bgcolor=gg)
Lol... by the way gg must be an interesting color :)
Aral
__
([EMAIL PROTECTED])
New Media Producer, Kismia, Inc.
([EMAIL PROTECTED])
Adj. Prof., American University
¯¯
--
PHP General Mailing List
body.*
Try this: /\body[^\]*\/
Hope this helps
Kristian
--
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]
body[^\]* worked... thanks Kristian...
As I get it -- match body then any number of characters that aren't greater
than signs then a greater than sign -- Is that right? (I'm really trying to
get my head around this regex thing.)
Thanks,
Aral :)
__
([EMAIL
9 matches
Mail list logo