RE: [PHP] LOL, preg_match still not working.

2007-02-20 Thread Richard Lynch
On Sat, February 17, 2007 8:50 am, Beauford wrote:
> I've been over this a thousand times with various users on this list
> and
> escaping this and escaping that just doesn't matter.
>
> The error is that it thinks valid characters are invalid. In the case
> of the
> example I included, the ! and the period are invalid, which they
> should not
> be.
>
> The nocomments and invalidchars are constants.
>
> Thanks
>
>> -Original Message-
>> From: Ray Hauge [mailto:[EMAIL PROTECTED]
>> Sent: February 17, 2007 9:45 AM
>> To: Beauford
>> Cc: PHP
>> Subject: Re: [PHP] LOL, preg_match still not working.
>>
>> Maybe you just copied it wrong, but nocomments and
>> invalidchars are not
>> quoted, or they're constants.
>>
>> I don't think you have to, but you might need to escape some of the
>> characters (namely * and .) in your regex.  It's been a while, so
>> I'd
>> have to look it up.
>>
>> What's the error you are getting?
>>
>> Ray Hauge
>> Primate Applications
>>
>>
>> Beauford wrote:
>> > Hi,
>> >
>> > I previously had some issues with preg_match and many of
>> you tried to help,
>> > but the same  problem still exists. Here it is again, if
>> anyone can explain
>> > to me how to get this to work it would be great - otherwise
>> I'll just remove
>> > it as I just spent way to much time on this.
>> >
>> > Thanks
>> >
>> > Here's the code.
>> >
>> >if(empty($comment)) { $formerror['comment'] = nocomments;
>> >}
>> >elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|',

I believe you want:
'|[EMAIL PROTECTED]&\\*\\(\\);:_\\. /\\t-]+$|'

In particular:
? means "maybe or maybe not the last PCRE expression", so the ! was
maybe or maybe not exluded.  Escape the ? with \\?

$ means "end", so escape that.

* means 0 or more, so escape that.

( and ) are used to capture the contents of a matching sub-expresson. 
Escape those.

. means ANY character, so escape that.

\t would work only inside of "" in PHP, not '', so you want PHP \\t to
turn into \t for PCRE which I think turns into a tab character... 
Actually, change the ' to " and use \t and then I'm *sure* it is a
tab.

I'm almost for sure that at least some of the above is utter nonsense
inside the [] where the "special" characters are not "special" at all,
but I can never remember the rules, and since '\\x' for a non-special
character turns into 'x' anyway, it doesn't "hurt" -- though it does
clutter up the PCRE for an expert, who wonders why the heck you did
that...

You should also re-read http://php.net/pcre and the two main pages
after that yet again.  I've read them 500 times, and some of it has
actually sunk in, so you're probably only got another 50 or so to go
before it works for you :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] LOL, preg_match still not working.

2007-02-17 Thread Peter Lauri
Haha,

This reminds me of a story about some IRC chat somewhere where someone was
asking how to control a media player thru the command line. It ended up with
him executing rm -rf / as root and then complaining that the machine was
slow when he executed it, and then he disappeared from the IRC... I wonder
why? :)

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free



-Original Message-
From: Vahan Yerkanian [mailto:[EMAIL PROTECTED] 
Sent: Saturday, February 17, 2007 7:02 PM
To: php-general@lists.php.net
Subject: Re: [PHP] LOL, preg_match still not working.

Correcting myself before my reply damages someone's box:

Vahan Yerkanian wrote:
> rm -rf /usr/local/lib/*

This indeed should be:

rm -rf /usr/local/lib/php/*

instead ;)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] LOL, preg_match still not working.

2007-02-17 Thread Beauford
I am running PHP 4.4.4 on Slackware 10. 

> -Original Message-
> From: Vahan Yerkanian [mailto:[EMAIL PROTECTED] 
> Sent: February 17, 2007 11:58 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] LOL, preg_match still not working.
> 
> Are you running under FreeBSD 6.2 and/or upgraded recently 
> from 5.2.1 to 
> 5.2.2?
> 
> I had the same problem on FreeBSD 6.2, with php5 installed from ports 
> collection after I portupgraded to 5.2.1.
> 
> For me it appeared to be some kind weird misconfiguration 
> problem that 
> happened during the portupgrade...
> 
> I had to:
> 
> pkg_delete -rv "php5*"
> rm -rf /var/db/ports/php5*
> rm -rf /usr/local/lib/*
> cd /usr/ports/lang/php5
> make install clean
> cd /usr/ports/lang/php5-extensions
> make install clean
> 
> A bit harsh, but all of the preg_* errors disappeared since then.
> 
> HTH,
> Vahan
> 
> 
> Steffen Ebermann wrote:
> > Addendum: I encountered a problem when the string contains 
> linebreaks. Maybe
> > adding \n\r into the brackets fixes your problem.
> > 
> > 
> > On Sat, Feb 17, 2007 at 09:27:59AM -0500, Beauford wrote:
> >> Hi,
> >>
> >> I previously had some issues with preg_match and many of 
> you tried to help,
> >> but the same  problem still exists. Here it is again, if 
> anyone can explain
> >> to me how to get this to work it would be great - 
> otherwise I'll just remove
> >> it as I just spent way to much time on this.
> >>
> >> Thanks
> >>
> >> Here's the code.
> >>
> >>if(empty($comment)) { $formerror['comment'] = nocomments; 
> >>}
> >>elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|',
> >> $comment)) {
> >>$formerror['comment'] = invalidchars;
> >>}   
> >>
> >> This produces an error, which I believe it should not.
> >>
> >> Testing 12345. This is a test of the emergency broadcast system.
> >>
> >> WAKE UP!!
> >>
> >> -- 
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> > 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LOL, preg_match still not working.

2007-02-17 Thread Steffen Ebermann
It's 6.2 but PHP 4.4.4.

Basically, I'm not getting any error. The expression just don't match. I
don't know if it should or not.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LOL, preg_match still not working.

2007-02-17 Thread Vahan Yerkanian

Correcting myself before my reply damages someone's box:

Vahan Yerkanian wrote:

rm -rf /usr/local/lib/*


This indeed should be:

rm -rf /usr/local/lib/php/*

instead ;)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LOL, preg_match still not working.

2007-02-17 Thread Vahan Yerkanian
Are you running under FreeBSD 6.2 and/or upgraded recently from 5.2.1 to 
5.2.2?


I had the same problem on FreeBSD 6.2, with php5 installed from ports 
collection after I portupgraded to 5.2.1.


For me it appeared to be some kind weird misconfiguration problem that 
happened during the portupgrade...


I had to:

pkg_delete -rv "php5*"
rm -rf /var/db/ports/php5*
rm -rf /usr/local/lib/*
cd /usr/ports/lang/php5
make install clean
cd /usr/ports/lang/php5-extensions
make install clean

A bit harsh, but all of the preg_* errors disappeared since then.

HTH,
Vahan


Steffen Ebermann wrote:

Addendum: I encountered a problem when the string contains linebreaks. Maybe
adding \n\r into the brackets fixes your problem.


On Sat, Feb 17, 2007 at 09:27:59AM -0500, Beauford wrote:

Hi,

I previously had some issues with preg_match and many of you tried to help,
but the same  problem still exists. Here it is again, if anyone can explain
to me how to get this to work it would be great - otherwise I'll just remove
it as I just spent way to much time on this.

Thanks

Here's the code.

	if(empty($comment)) { $formerror['comment'] = nocomments; 
	}

elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|',
$comment)) {
$formerror['comment'] = invalidchars;
}   

This produces an error, which I believe it should not.

Testing 12345. This is a test of the emergency broadcast system.

WAKE UP!!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LOL, preg_match still not working.

2007-02-17 Thread Steffen Ebermann
Addendum: I encountered a problem when the string contains linebreaks. Maybe
adding \n\r into the brackets fixes your problem.


On Sat, Feb 17, 2007 at 09:27:59AM -0500, Beauford wrote:
> Hi,
> 
> I previously had some issues with preg_match and many of you tried to help,
> but the same  problem still exists. Here it is again, if anyone can explain
> to me how to get this to work it would be great - otherwise I'll just remove
> it as I just spent way to much time on this.
> 
> Thanks
> 
> Here's the code.
> 
>   if(empty($comment)) { $formerror['comment'] = nocomments; 
>   }
>   elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|',
> $comment)) {
>   $formerror['comment'] = invalidchars;
>   }   
> 
> This produces an error, which I believe it should not.
> 
> Testing 12345. This is a test of the emergency broadcast system.
> 
> WAKE UP!!
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LOL, preg_match still not working.

2007-02-17 Thread Steffen Ebermann
As far as I tested, the regular expression works how it is
intended to work.

Maybe this a touch easier to read line do it for you:

  elseif (preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]|', $comment))



On Sat, Feb 17, 2007 at 09:27:59AM -0500, Beauford wrote:
> Hi,
> 
> I previously had some issues with preg_match and many of you tried to help,
> but the same  problem still exists. Here it is again, if anyone can explain
> to me how to get this to work it would be great - otherwise I'll just remove
> it as I just spent way to much time on this.
> 
> Thanks
> 
> Here's the code.
> 
>   if(empty($comment)) { $formerror['comment'] = nocomments; 
>   }
>   elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|',
> $comment)) {
>   $formerror['comment'] = invalidchars;
>   }   
> 
> This produces an error, which I believe it should not.
> 
> Testing 12345. This is a test of the emergency broadcast system.
> 
> WAKE UP!!
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] LOL, preg_match still not working.

2007-02-17 Thread Beauford
I've been over this a thousand times with various users on this list and
escaping this and escaping that just doesn't matter.

The error is that it thinks valid characters are invalid. In the case of the
example I included, the ! and the period are invalid, which they should not
be.

The nocomments and invalidchars are constants.

Thanks

> -Original Message-
> From: Ray Hauge [mailto:[EMAIL PROTECTED] 
> Sent: February 17, 2007 9:45 AM
> To: Beauford
> Cc: PHP
> Subject: Re: [PHP] LOL, preg_match still not working.
> 
> Maybe you just copied it wrong, but nocomments and 
> invalidchars are not 
> quoted, or they're constants.
> 
> I don't think you have to, but you might need to escape some of the 
> characters (namely * and .) in your regex.  It's been a while, so I'd 
> have to look it up.
> 
> What's the error you are getting?
> 
> Ray Hauge
> Primate Applications
> 
> 
> Beauford wrote:
> > Hi,
> > 
> > I previously had some issues with preg_match and many of 
> you tried to help,
> > but the same  problem still exists. Here it is again, if 
> anyone can explain
> > to me how to get this to work it would be great - otherwise 
> I'll just remove
> > it as I just spent way to much time on this.
> > 
> > Thanks
> > 
> > Here's the code.
> > 
> > if(empty($comment)) { $formerror['comment'] = nocomments; 
> > }
> > elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|',
> > $comment)) {
> > $formerror['comment'] = invalidchars;
> > }   
> > 
> > This produces an error, which I believe it should not.
> > 
> > Testing 12345. This is a test of the emergency broadcast system.
> > 
> > WAKE UP!!
> > 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] LOL, preg_match still not working.

2007-02-17 Thread Ray Hauge
Maybe you just copied it wrong, but nocomments and invalidchars are not 
quoted, or they're constants.


I don't think you have to, but you might need to escape some of the 
characters (namely * and .) in your regex.  It's been a while, so I'd 
have to look it up.


What's the error you are getting?

Ray Hauge
Primate Applications


Beauford wrote:

Hi,

I previously had some issues with preg_match and many of you tried to help,
but the same  problem still exists. Here it is again, if anyone can explain
to me how to get this to work it would be great - otherwise I'll just remove
it as I just spent way to much time on this.

Thanks

Here's the code.

	if(empty($comment)) { $formerror['comment'] = nocomments; 
	}

elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|',
$comment)) {
$formerror['comment'] = invalidchars;
}   

This produces an error, which I believe it should not.

Testing 12345. This is a test of the emergency broadcast system.

WAKE UP!!



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] LOL, preg_match still not working.

2007-02-17 Thread Beauford
Hi,

I previously had some issues with preg_match and many of you tried to help,
but the same  problem still exists. Here it is again, if anyone can explain
to me how to get this to work it would be great - otherwise I'll just remove
it as I just spent way to much time on this.

Thanks

Here's the code.

if(empty($comment)) { $formerror['comment'] = nocomments; 
}
elseif(!preg_match('|[EMAIL PROTECTED]&*();:_. /\t-]+$|',
$comment)) {
$formerror['comment'] = invalidchars;
}   

This produces an error, which I believe it should not.

Testing 12345. This is a test of the emergency broadcast system.

WAKE UP!!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php