words condition dont match

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
visonardo
Forum Contributor
Posts: 136
Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.

words condition dont match

Post 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
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post 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.
User avatar
visonardo
Forum Contributor
Posts: 136
Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.

Post 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?
User avatar
visonardo
Forum Contributor
Posts: 136
Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You are using zero width assertions. That you get an "=" means that your pattern was found somewhere in your haystack.
User avatar
visonardo
Forum Contributor
Posts: 136
Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You're still using zero width assertions. What specifically are you trying to accomplish?
User avatar
visonardo
Forum Contributor
Posts: 136
Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.

Post 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 :?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What's this for? Are you trying to build a php based browser of sorts?
User avatar
visonardo
Forum Contributor
Posts: 136
Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.

Post 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? :?:
User avatar
visonardo
Forum Contributor
Posts: 136
Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

As far as I know that is the correct statement for this particular header value.
User avatar
visonardo
Forum Contributor
Posts: 136
Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.

Post 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:
Post Reply