Page 1 of 1

words condition dont match

Posted: Fri Dec 15, 2006 10:16 am
by visonardo

Code: Select all

$b='DEF=abc abc=DEF';
preg_match("/(?!abc)=(?!def)/i",$b,$enc);
echo '<pre>';
print_r($enc);
echo '</pre>';
$enc[0] should has

Code: Select all

DEF=abc
:? and dont take that

Posted: Fri Dec 15, 2006 10:25 am
by jayshields
You really need to revise your take on the English language and punctuation or you're not going to get much help around here. I cannot understand what point you're trying to make, and I doubt anyone else can grasp it that well either.

Posted: Fri Dec 15, 2006 10:35 am
by visonardo
jayshields wrote:You really need to revise your take on the English language and punctuation or you're not going to get much help around here. I cannot understand what point you're trying to make, and I doubt anyone else can grasp it that well either.

ok


the problem is that i have this code:

Code: Select all

preg_match("/(?!abc)=(?!def)/i",'DEF=abc abc=DEF',$enc);
print_r($enc);
SHOWN OUTPUT:

Code: Select all

Array
(
    [0] => =
)

DESIRED OUTPUT:

Code: Select all

Array
(
    [0] => DEF=abc
)

what is bad here?

Posted: Fri Dec 15, 2006 12:32 pm
by visonardo
i need take cookie´s name from

Code: Select all

Set-Cookie: name=value; expires=xxxxxxxxxx; domain=xxxxxx; path=/
and whe know that this value can appear anywhere, not need to be first of all.

i thought to do thus:

Code: Select all

$a='Set-Cookie: name=value; expires=xxxxxxxxxx; domain=xxxxxx; path=/';
preg_match("/(?!domain|expires|path)=([^;\r\n]*)/i",$a,$enc);
print_r($enc);
but the output is:

Code: Select all

Array
(
    [0] => =value
    [1] => value
)
:? dont take name field

Posted: Fri Dec 15, 2006 5:05 pm
by feyd
You are using zero width assertions. That you get an "=" means that your pattern was found somewhere in your haystack.

Posted: Fri Dec 15, 2006 5:24 pm
by visonardo
now i used (?<!word...) and does the same :?

Code: Select all

$a='Set-Cookie: name=value; expires=xxxxxxxxxx; domain=xxxxxx; path=/';
preg_match("/(?<!domain|expires|path)=([^;\r\n]*)/i",$a,$enc);
print_r($enc);

OUTPUT:

Code: Select all

Array
(
    [0] => =value
    [1] => value
)

where is the problem?

Posted: Fri Dec 15, 2006 5:29 pm
by feyd
You're still using zero width assertions. What specifically are you trying to accomplish?

Posted: Fri Dec 15, 2006 6:03 pm
by visonardo
feyd wrote:You're still using zero width assertions. What specifically are you trying to accomplish?

i need take the name and their value of cookie that this cookie header would set, i dont know their name, just i know that is a word different that "domain", "path" and "expires". then is continued by = simbol and then by a value (string) thus ([^;\r\n]*) just i know that. with this info i need take the name and name´s value of a determinated cookie header. Its that i want, hope be clear my english :?

Posted: Fri Dec 15, 2006 6:19 pm
by feyd
What's this for? Are you trying to build a php based browser of sorts?

Posted: Fri Dec 15, 2006 6:34 pm
by visonardo
i guess that the problem was fixed, just i tell you to tell me if im mistaken, because perhaps this document is old and is another new that say the contrarie.

Code: Select all

The NAME=VALUE attribute-value pair MUST come first in each cookie.
says in http://tools.ietf.org/html/rfc2965 section 3.2.2

i trust about that or continue like i was doing? :?:

Posted: Fri Dec 15, 2006 6:36 pm
by visonardo
feyd wrote:What's this for? Are you trying to build a php based browser of sorts?
i read pages content with fsockopen and keep their cookies in a another cookie of site where i do

Posted: Fri Dec 15, 2006 6:36 pm
by feyd
As far as I know that is the correct statement for this particular header value.

Posted: Fri Dec 15, 2006 6:44 pm
by visonardo
feyd wrote:As far as I know that is the correct statement for this particular header value.
8O , i was asking about that so long :?

ok, no problem, thank :wink: