Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
visonardo
Forum Contributor
Posts: 136 Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.
Post
by visonardo » Fri Dec 15, 2006 10:16 am
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
and dont take that
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Fri Dec 15, 2006 10:25 am
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.
visonardo
Forum Contributor
Posts: 136 Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.
Post
by visonardo » Fri Dec 15, 2006 10:35 am
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:
DESIRED OUTPUT:
what is bad here?
visonardo
Forum Contributor
Posts: 136 Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.
Post
by visonardo » Fri Dec 15, 2006 12:32 pm
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Dec 15, 2006 5:05 pm
You are using zero width assertions. That you get an "=" means that your pattern was found somewhere in your haystack.
visonardo
Forum Contributor
Posts: 136 Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.
Post
by visonardo » Fri Dec 15, 2006 5:24 pm
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Dec 15, 2006 5:29 pm
You're still using zero width assertions. What specifically are you trying to accomplish?
visonardo
Forum Contributor
Posts: 136 Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.
Post
by visonardo » Fri Dec 15, 2006 6:03 pm
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Dec 15, 2006 6:19 pm
What's this for? Are you trying to build a php based browser of sorts?
visonardo
Forum Contributor
Posts: 136 Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.
Post
by visonardo » Fri Dec 15, 2006 6:34 pm
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?
visonardo
Forum Contributor
Posts: 136 Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.
Post
by visonardo » Fri Dec 15, 2006 6:36 pm
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Dec 15, 2006 6:36 pm
As far as I know that is the correct statement for this particular header value.
visonardo
Forum Contributor
Posts: 136 Joined: Mon Oct 02, 2006 7:49 pm
Location: Argentina, South America´s Sun.
Post
by visonardo » Fri Dec 15, 2006 6:44 pm
feyd wrote: As far as I know that is the correct statement for this particular header value.
, i was asking about that so long
ok, no problem, thank