ereg question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a little problem with ereg (eregi) in PHP - in some cases it behaves
differently than I expect and I don`t know if my expectations are strange or
there is any "syntax subtlety" I have missed.

I want to find a value for key1 in string:

key1=>value_of key1[EOT]key2=>other_value[EOT]key3=>value[3][EOT]

and  I use an ereg pattern


unfortunately ereg match differs from "value_of key1", which I wanted to
receive. Ereg finds the last apperance of [EOT] in string $line and the
value of $regs[1] is

"key1=>value_of key1[EOT]key2=>other_value[EOT]key3=>value[3]"

Can I achieve an effect, that ereg matches the first occurence of [EOT] and
as a result I`'ll get "value_of key1" as a result?

Thanks for help

Re: ereg question

Rafal Zak wrote:

Quoted text here. Click to load it

The * in "([[:print:][:space:]]*)" will also match the first "[EOT]"
because they are all print characters. You'd need to use a negative
look-ahead or something along those lines, but I do not know if that is
supported in ereg patterns....

Justin Koivisto -

Site Timeline