Re: [PHP] Eregi error

2007-03-01 Thread Richard Lynch
On Thu, March 1, 2007 6:14 pm, Myron Turner wrote:
> Roberto Mansfield wrote:
>> Myron Turner wrote:
>>
>>> M.Sokolewicz wrote:
>>>
>>$pattern = '^[a-z0-9\!\_ \.- ,/]*$';
>>if(!eregi($pattern, $input)){
>>
>>> the problem is that the hyphen is interpreted as regex range
>>> operator:
>>>  [a-z0-9\!\_ \.- ,/]
>>> Rewrite this as
>>>[a-z0-9\!\_ \. ,/-]
>>> with the hyphen in the last position.
>>>
>>>
>>
>> Or just escape the hyphen: \-
>> The position won't matter.
>>
>>
>
> Actually, I tried that, but it didn't work.  It still saw the hyphen
> as
> an operator.  The other thing about this is that the hyphen is
> followed
> by a space, so that it's asking for a range between the period and the
> space, which you can't do, since the space character has a lower ascii
> value than than the period.  The space is more obvious in a monospaced
> font.

The reason that a single \ in front didn't work is that \ is ALSO
special character for ' in PHP, and it just escapes the - so that you
have NOT sent \- to EREG, but sent it the same thing you were sending
it before you added \

You would need \\ inside of '' (or "") in PHP to get a single \ sent
to EREG which would then be used by EREG to escape the -

'...\\- ,/'

PHP takes \\- to produce \- which EREG takes to produce [character -]
instead of [range operator -]

You should probably review the "strings" page at the beginning of the
PHP manual.

-- 
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] Eregi error

2007-03-01 Thread Myron Turner

Roberto Mansfield wrote:

Myron Turner wrote:
  

M.Sokolewicz wrote:


   $pattern = '^[a-z0-9\!\_ \.- ,/]*$';
   if(!eregi($pattern, $input)){
  

the problem is that the hyphen is interpreted as regex range operator:
 [a-z0-9\!\_ \.- ,/]
Rewrite this as
   [a-z0-9\!\_ \. ,/-]
with the hyphen in the last position.




Or just escape the hyphen: \-
The position won't matter.

  


Actually, I tried that, but it didn't work.  It still saw the hyphen as 
an operator.  The other thing about this is that the hyphen is followed 
by a space, so that it's asking for a range between the period and the 
space, which you can't do, since the space character has a lower ascii 
value than than the period.  The space is more obvious in a monospaced font.


--

_
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

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



Re: [PHP] Eregi error

2007-03-01 Thread Richard Lynch
On Wed, February 28, 2007 9:08 pm, Brad wrote:
> I have been having some trouble with the "eregi" function. I have the
> following piece of code in my application:
>
> function standard_input($input, $min=0, $max=50){
> if (strlen($input) <= $max and strlen($input) >= $min ) {
> $pattern = '^[a-z0-9\!\_ \.- ,/]*$';

It means that the bit that hs .- , above makes ZERO sense, because ,
comes before . in ASCII, so you can't do that range you just tried to
do.

Of course, you weren't actually trying to do a RANGE, but when you
tacked ' ,/' onto your pattern, you weren't paying attention to the
fact that - has to be at the very end, or very beginning, or (maybe?)
escaped so that EREG knows it's not a RANGE you are defining, but a
single character in the character set.

-- 
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] Eregi error

2007-03-01 Thread Roberto Mansfield
Myron Turner wrote:
> M.Sokolewicz wrote:
$pattern = '^[a-z0-9\!\_ \.- ,/]*$';
if(!eregi($pattern, $input)){
> 
> the problem is that the hyphen is interpreted as regex range operator:
>  [a-z0-9\!\_ \.- ,/]
> Rewrite this as
>[a-z0-9\!\_ \. ,/-]
> with the hyphen in the last position.
> 

Or just escape the hyphen: \-
The position won't matter.

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



Re: [PHP] Eregi error

2007-03-01 Thread Myron Turner

M.Sokolewicz wrote:

Hey all,
I have been having some trouble with the "eregi" function. I have 
the following piece of code in my application:


   function standard_input($input, $min=0, $max=50){
   if (strlen($input) <= $max and strlen($input) >= $min ) {
   $pattern = '^[a-z0-9\!\_ \.- ,/]*$';
   if(!eregi($pattern, $input)){
   return false;
   }else{
   return true;
   }
   }else{
   return false;
   }
 }

And i am running PHP version 5.2.1

I receive the following error:
*Warning*: eregi() [function.eregi 
]: 
REG_ERANGE in *[File Location]* on line *287


the problem is that the hyphen is interpreted as regex range operator:
 [a-z0-9\!\_ \.- ,/]
Rewrite this as
   [a-z0-9\!\_ \. ,/-]
with the hyphen in the last position.

--

_
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

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



Re: [PHP] Eregi error

2007-03-01 Thread M.Sokolewicz
I agree with the first part, that it is in many cases better to use the 
Perl Compatible Regular Expressions (PCRE, preg_*) than the POSIX 
compatible ones (ereg[i]_*). However, I don't quite get what you mean by 
"extension is useless" ? What extension...?? and why would it be 
useless? (useless in what way?)


- tul

Nicholas Yim wrote:

Hello Brad,

   suggest to use preg_* instead of ereg_*

   extension is useless

Best regards, 
  
=== At 2007-03-01, 11:12:52 you wrote: ===



Hey all,
I have been having some trouble with the "eregi" function. I have the 
following piece of code in my application:


   function standard_input($input, $min=0, $max=50){
   if (strlen($input) <= $max and strlen($input) >= $min ) {
   $pattern = '^[a-z0-9\!\_ \.- ,/]*$';
   if(!eregi($pattern, $input)){
   return false;
   }else{
   return true;
   }
   }else{
   return false;
   }
  
   }


And i am running PHP version 5.2.1

I receive the following error:
*Warning*: eregi() [function.eregi 
]: 
REG_ERANGE in *[File Location]* on line *287


*Any ideas what might cause this? Googling REG_ERANGE only showed more 
questions.


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




= = = = = = = = = = = = = = = = = = = =

Nicholas Yim
[EMAIL PROTECTED]
2007-03-01


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



Re: [PHP] Eregi error

2007-03-01 Thread Nicholas Yim
Hello Brad,

   suggest to use preg_* instead of ereg_*

   extension is useless

Best regards, 
  
=== At 2007-03-01, 11:12:52 you wrote: ===

>
>Hey all,
>I have been having some trouble with the "eregi" function. I have the 
>following piece of code in my application:
>
>function standard_input($input, $min=0, $max=50){
>if (strlen($input) <= $max and strlen($input) >= $min ) {
>$pattern = '^[a-z0-9\!\_ \.- ,/]*$';
>if(!eregi($pattern, $input)){
>return false;
>}else{
>return true;
>}
>}else{
>return false;
>}
>   
>}
>
>And i am running PHP version 5.2.1
>
>I receive the following error:
>*Warning*: eregi() [function.eregi 
>]: 
>REG_ERANGE in *[File Location]* on line *287
>
>*Any ideas what might cause this? Googling REG_ERANGE only showed more 
>questions.
>
>-- 
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>

= = = = = = = = = = = = = = = = = = = =

Nicholas Yim
[EMAIL PROTECTED]
2007-03-01

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



RE: [PHP] Eregi error

2007-02-28 Thread Peter Lauri
Not sure, but I don't think you should escape all those characters inside of
the character class. I might be wrong. However, that might not have anything
to do with the error. But I do think you need to escape the / in the end...
And the - you should have in the beginning of the character class, otherwise
it will be treated as a range.

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: Brad [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 01, 2007 5:09 AM
To: PHP Mailing
Subject: [PHP] Eregi error


Hey all,
I have been having some trouble with the "eregi" function. I have the 
following piece of code in my application:

function standard_input($input, $min=0, $max=50){
if (strlen($input) <= $max and strlen($input) >= $min ) {
$pattern = '^[a-z0-9\!\_ \.- ,/]*$';
if(!eregi($pattern, $input)){
return false;
}else{
return true;
}
}else{
return false;
}
   
}

And i am running PHP version 5.2.1

I receive the following error:
*Warning*: eregi() [function.eregi 
]: 
REG_ERANGE in *[File Location]* on line *287

*Any ideas what might cause this? Googling REG_ERANGE only showed more 
questions.

-- 
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] eregi problem

2005-04-03 Thread Josip Dzolonga
[EMAIL PROTECTED] wrote:
if((eregi("[^a-zA-Z0-9]",$GP[sifre])
I think that the ^ anchor is your problem, it shall be out of the brackets :
if (eregi("^[a-zA-Z0-9]+$", $GP['sifre'])) echo 'true';
else echo 'false';
(the above is tested and works perfect)
P.S. Take a look here 
http://www.php.net/manual/en/language.types.array.php#language.types.array.donts

--
Josip Dzolonga
http://josip.dotgeek.org
jdzolonga[at]gmail.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] eregi problem

2005-04-03 Thread BAO RuiXian

[EMAIL PROTECTED] wrote:
I m trying to check $GP[sifre] variable, $GP[sifre] must consist of alpha
numeric chars only. here, how I check the variable:
 

Try this:
if(eregi("^[a-zA-Z0-9]+$",$GP[sifre]))
The above say that between the beginning of the string "^" and the end 
of the string "$", there are only alpha-numeric characters but at least 
one. Note, your following code has syntax error.

Best
Bao
 

if((eregi("[^a-zA-Z0-9]",$GP[sifre])
   echo 'true';
else
   echo 'false';
It works if variable starts with alphabetic chars only.
for example this returns 'ok'
   $GP[sifre]='blabla234243';
but this does not work: (if variable starts with numeric chars)
   $GP[sifre]='3243242blabla';
second one returns false, couldnt figure out the problem here. any help ?
 

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


RE: [PHP] Eregi question

2004-03-11 Thread Dave Carrera
Thanks da koenich,

Although $temp[0] gives me the domain name rather than the tld but thanks
very much for your help, I knew it was easy :-)

Yours Truly

Dave C



-Original Message-
From: Da Koenich [mailto:[EMAIL PROTECTED] 
Sent: 11 March 2004 15:19
To: Dave Carrera
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Eregi question


hi dave,

try this:

$temp = explode('.',$_POST['variable']);
$domainname = $temp[1];

greetz
da koenich

> Hi List,
> 
> I Know this is basic and I am sorry to bother the list with this 
> question but I am confused, probably working to hard :-)
> 
> I want to end up with a part of a string returned by $_POST to work 
> with in my function.
> 
> The string might be put into the text box like so, it’s a domain name 
> checker,
> 
> http://www.domainname.com
> 
> I have already got rid of the http:// and www bits but I need to know 
> how to get rid of the .com bit before proceeding with my check. So I 
> will only be left with "domainname" for my function.
> 
> I have looked at eregi, split, spliti but to no joy so any help would 
> be gratefully received.
> 
> Thank you in advance for any help
> 
> Dave C
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.619 / Virus Database: 398 - Release Date: 10/03/2004
>  



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.619 / Virus Database: 398 - Release Date: 10/03/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.619 / Virus Database: 398 - Release Date: 10/03/2004
 

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



Re: [PHP] Eregi question

2004-03-11 Thread Jason Wong
On Thursday 11 March 2004 22:50, Dave Carrera wrote:

> I want to end up with a part of a string returned by $_POST to work with in
> my function.
>
> The string might be put into the text box like so, it’s a domain name
> checker,
>
> http://www.domainname.com
>
> I have already got rid of the http:// and www bits but I need to know how
> to get rid of the .com bit before proceeding with my check. So I will only
> be left with "domainname" for my function.
>
> I have looked at eregi, split, spliti but to no joy so any help would be
> gratefully received.

Why don't you just explode() on '.' and then pick the bits you need?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The power to destroy a planet is insignificant when compared to the power of
the Force.
- Darth Vader
*/

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



Re: [PHP] Eregi question

2004-03-11 Thread Da Koenich
hi dave,

try this:

$temp = explode('.',$_POST['variable']);
$domainname = $temp[1];

greetz
da koenich

> Hi List,
> 
> I Know this is basic and I am sorry to bother the list with this question
> but I am confused, probably working to hard :-)
> 
> I want to end up with a part of a string returned by $_POST to work with in
> my function.
> 
> The string might be put into the text box like so, it’s a domain name
> checker,
> 
> http://www.domainname.com
> 
> I have already got rid of the http:// and www bits but I need to know how to
> get rid of the .com bit before proceeding with my check. So I will only be
> left with "domainname" for my function.
> 
> I have looked at eregi, split, spliti but to no joy so any help would be
> gratefully received.
> 
> Thank you in advance for any help
> 
> Dave C
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.619 / Virus Database: 398 - Release Date: 10/03/2004
>  

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



RE: [PHP] eregi filter stopping valid email address, part two

2004-01-06 Thread Dave G
Mike,

> No.  You've only allowed for hyphens in the first element 
> after the @ sign
> -- this address has them in the 2nd element.

Ah, yes, I guess I had it that way because there are no hyphens in top
level domain designations, but hadn't accounted for the fact that it
would exclude them if there were more elements.
Thanks for pointing that out.

John,
Thank you for pointing out the period matching problem! I will
adjust my syntax as you suggest.

Manuel,
The classes you recommend are probably more robust than what I'm
accomplishing on my own. I will look into using them. Thank you for the
link.

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



Re: [PHP] eregi filter stopping valid email address, part two

2004-01-06 Thread CPT John W. Holmes
From: "Dave G" <[EMAIL PROTECTED]>

> A while ago on this list I posted a few questions about an eregi
> filter for email addresses entered into a form. With the help of people
> on this list, I settled on the following code which has worked fine in
> the months since I started using it. The code is this:
>
> eregi('[EMAIL PROTECTED]', $email)
>
> But recently, a person was unable to get their email to pass
> this eregi test. The email is valid, as they are able to send email to
> me. It has the following format:
>
> [EMAIL PROTECTED]
>
> Shouldn't this email pass? I've allowed for hyphens after the @
> mark. Is it that there are two many periods?

You're only allowing hyphens in the first part of the address after the @
symbol, though, before the first period. Maybe your regex should be:

@([a-zA-Z0-9-]+\.)+[a-zA-Z.]

Just noticed that your period is not escaped, either, so you're actually
matching any character with the one that's outside of the [ and ] character
classes.

---John Holmes...

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



RE: [PHP] eregi filter stopping valid email address, part two

2004-01-06 Thread Ford, Mike [LSS]
On 06 January 2004 15:53, Dave G wrote:

> PHP Gurus
> 
>   A while ago on this list I posted a few questions about an eregi
> filter for email addresses entered into a form. With the help
> of people
> on this list, I settled on the following code which has worked fine in
> the months since I started using it. The code is this:
> 
> eregi('[EMAIL PROTECTED]', $email)
> 
>   But recently, a person was unable to get their email to pass
> this eregi test. The email is valid, as they are able to send email to
> me. It has the following format:
> 
> [EMAIL PROTECTED]
> 
>   Shouldn't this email pass? I've allowed for hyphens after the @
> mark. Is it that there are two many periods?

No.  You've only allowed for hyphens in the first element after the @ sign
-- this address has them in the 2nd element.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP] Re: PHP eregi filtering problem

2003-12-08 Thread Sven
Purpleonyx schrieb:
Greetings all, I ran into a problem today and was
hoping someone could provide an answer.
I am fetching a web page, and attempting to parse
certain variables from it.  I've done this plenty of
times in the past with no problem.  The only
difference this time is the file that I am parsing is
much larger.  The HTML file is about 42kb in size
(usually I only parse ~4kb worth).  In the web
browser, the script seems to just shut down, but
reports no errors, not even to the web server logs. 
Is there some specific max size that it can accept or
a setting in php.ini I need to modify?

Thanks
hi,

i don't think, that 42k is too much for the size of your file. mut maybe 
php simply times out while parsing? there is a php.ini-parameter 
max_execution_time and a runtime-function set_time_limit(). try 
set_time_limit(0) at top of your script fo debugging.

also take a look at preg_* functions instead of ereg_*. they are said to 
be much faster.

hth SVEN

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


Re: [PHP] eregi function?

2003-11-26 Thread Jason Wong
On Wednesday 26 November 2003 06:32, Jas wrote:
> Not sure how to do this but I have a call to a database which pulls the
> contents of a table into an array and I need a eregi string which will
> sift through the contents and put a line break (i.e. \n or ) after
> each ";", "}" or "{".  

If that is exactly what you need, then use str_replace().

>here is what I have so far...

[snip]

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The Illiterati Programus Canto 1:
A program is a lot like a nose: Sometimes it runs, and
sometimes it blows.
*/

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



Re: [PHP] eregi function?

2003-11-25 Thread John W. Holmes
Jas wrote:

Not sure how to do this but I have a call to a database which pulls the 
contents of a table into an array and I need a eregi string which will 
sift through the contents and put a line break (i.e. \n or ) after 
each ";", "}" or "{".  here is what I have so far...
function callback(&$value,$key)
{ $value = preg_replace('/([;{}])/',"$1\n",$value); }
while($b = mysql_fetch_array($sql)) {
array_walk($b,'callback');

And then continue on as normal.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


RE: [PHP] eregi function?

2003-11-25 Thread Chris W. Parker
Jas 
on Tuesday, November 25, 2003 2:32 PM said:

> Not sure how to do this but I have a call to a database which pulls
> the contents of a table into an array and I need a eregi string which
> will sift through the contents and put a line break (i.e. \n or )
> after each ";", "}" or "{".  here is what I have so far...

Try using eregi_replace() instead.



Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

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



Re: [PHP] eregi filter

2003-11-18 Thread John Nichel
John W. Holmes wrote:
Derek Ford wrote:

Erin wrote:
 > >

> Anyone have a good eregi filter for passwords?

well, for one thing, don't use ereg. Use pcre, as it is faster.

preg_match('/^[a-zA-Z0-9]{5,16}$/',$blah);
that will validate a password containing only upper or lowercase 
letters and numbers, between 5 and 16 characters.

So "a" is a good password?

It's an excelent password.  I think you should change your root password 
to that on all systems you have root on.  Oh, and another thingsend 
me the IP's to those machines. ;)

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] eregi filter

2003-11-18 Thread John W. Holmes
Derek Ford wrote:
Erin wrote:
> >
> Anyone have a good eregi filter for passwords?

well, for one thing, don't use ereg. Use pcre, as it is faster.

preg_match('/^[a-zA-Z0-9]{5,16}$/',$blah);
that will validate a password containing only upper or lowercase letters 
and numbers, between 5 and 16 characters.

So "a" is a good password?

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] eregi filter

2003-11-18 Thread John W. Holmes
Erin wrote:

Anyone have a good eregi filter for passwords?
Yes.

http://homepages.tesco.net/~J.deBoynePollard/FGA/questions-with-yes-or-no-answers.html

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] eregi filter

2003-11-18 Thread Derek Ford
Erin wrote:

Anyone have a good eregi filter for passwords?

Regards

R

 

well, for one thing, don't use ereg. Use pcre, as it is faster.

preg_match('/^[a-zA-Z0-9]{5,16}$/',$blah);
that will validate a password containing only upper or lowercase letters 
and numbers, between 5 and 16 characters.

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


Re: [PHP] Eregi filtering..

2003-07-07 Thread Mike Migurski
>elseif (eregi("a-ZA-9", $v_tel_filter)) {
>echo "'$v_tel_filter' Telephone Number Contains words";
>
>} else {
>
>im looking how to verify numbers alone and dash "-" can that be possible? I
>have tried using "a-ZA-9" but did not work.

/^[\-\d]+$/ should match a string of just digits and dashes.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html


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



RE: [PHP] Eregi filtering..

2003-07-07 Thread Miranda, Joel Louie M
Hey ralph, its you again! :) thanks, its now working..

> if(strrpos($v_tel_filter,' ') > 0 || strspn($v_tel_filter,
> "0123456789-") != strlen($v_tel_filter)){
>   echo "'$v_tel_filter' Telephone Number Contains words";
> } else {

I'll check on the syntax for strrpos, thanks!

--
Thank you,
Louie


-Original Message-
From: Ralph [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 08, 2003 8:20 AM
To: Miranda, Joel Louie M; [EMAIL PROTECTED]
Subject: RE: [PHP] Eregi filtering..


Here is one of doing this:

if(strrpos($v_tel_filter,' ') > 0 || strspn($v_tel_filter,
"0123456789-") != strlen($v_tel_filter)){
  echo "'$v_tel_filter' Telephone Number Contains words";
} else {


  
}


-Original Message-
From: Miranda, Joel Louie M [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 07, 2003 5:10 PM
To: '[EMAIL PROTECTED]'
Subject: [PHP] Eregi filtering..


elseif (eregi("a-ZA-9", $v_tel_filter)) { 
echo "'$v_tel_filter' Telephone Number Contains words"; 

} else { 

im looking how to verify numbers alone and dash "-" can that be possible? I
have tried using "a-ZA-9" but did not work. 

any ideas? 

thanks, 
louie



--
Thank you,
Louie

-- 
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] Eregi filtering..

2003-07-07 Thread Ralph
Here is one of doing this:

if(strrpos($v_tel_filter,' ') > 0 || strspn($v_tel_filter,
"0123456789-") != strlen($v_tel_filter)){
  echo "'$v_tel_filter' Telephone Number Contains words";
} else {


  
}


-Original Message-
From: Miranda, Joel Louie M [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 07, 2003 5:10 PM
To: '[EMAIL PROTECTED]'
Subject: [PHP] Eregi filtering..


elseif (eregi("a-ZA-9", $v_tel_filter)) { 
echo "'$v_tel_filter' Telephone Number Contains words"; 

} else { 

im looking how to verify numbers alone and dash "-" can that be
possible? I
have tried using "a-ZA-9" but did not work. 

any ideas? 

thanks, 
louie



--
Thank you,
Louie

-- 
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] eregi problems

2002-07-04 Thread Marek Kilimajer

If the regexp matches, it is a valid email, so you need ! in front of it.

dan radom wrote:

>I've got a form that's posted to a php page where I'm attempting to validate a field 
>contains a valid email address.  The eregi below seems to be totally ignored...
>
>  if (eregi("^[a-z0-9\._-]+@[a-z0-9\._-]+$", $emp_email)) {
>  echo "please enter a valid email address";
>  exit;
>  }
>
>
>$emp_email is being posted to the form.  Any ideas why this is being ignored?
>
>dan
>
>  
>



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




Re: [PHP] eregi problems

2002-07-04 Thread dan radom

My main cnocern at this point is that the eregi is being totally ignored.  I just want 
to make sure the email address is in a valid format, not that it is a valid email 
address.  I'll look at validEmailFormat as well, but I don't understand why it's not 
even being examined.

dan


* Justin French ([EMAIL PROTECTED]) wrote:
> Dan,
> 
> I'll give you a little piece of advise that was given to me a little while
> back on this list:
> 
> Go to http://www.killersoft.com/ and grab a copy of the validateEmailFormat
> program.
> 
> 
> PHP4 translation of Jeffrey E.F. Friedl's definitive Email Regex Program
> from O'Reilly's Mastering Regular Expressions.  This function is used to
> confirm if an e-mail address adheres to the RFC 822 specification for
> internet email addresses.
> 
> 
> Rather than trying re-invent the wheel, why not use something that conforms
> closely to specs, and is widely accepted by many development groups.
> 
> 
> All you'll have to do is something like (function names and filenames may
> not be right):
> 
>  include('inc/validEmailFormat.inc');
> if(!validEmailFormat($emp_email))
> {
> echo "please enter a valid email address";
> }
> ?>
> 
> 
> Side topic:  of course, you aren't checking for a valid email address at
> all, your checking to see if the email address LOOKS valid.  You're not
> checking to see if the address is attached to an email box, or furthermore
> if there's anyone at the other end to open/read your email... you're just
> validating the appearance of the address to fall within RFC 822 specs.
> 
> Subsequently [EMAIL PROTECTED] and [EMAIL PROTECTED]
> will both return valid.
> 
> 
> The only way to ensure an email address is truely valid is to send an email
> to it, and have them respond... indicating that the address is linked to an
> email box and furthermore, someone opened the email, read it, and responded.
> 
> Even then, this could be done by a robot I guess.
> 
> 
> Justin French
> 
> Creative Director
> http://Indent.com.au
> 
> 
> 
> 
> 
> on 05/07/02 12:23 AM, dan radom ([EMAIL PROTECTED]) wrote:
> 
> > I've got a form that's posted to a php page where I'm attempting to validate a
> > field contains a valid email address.  The eregi below seems to be totally
> > ignored...
> > 
> > if (eregi("^[a-z0-9\._-]+@[a-z0-9\._-]+$", $emp_email)) {
> > echo "please enter a valid email address";
> > exit;
> > }
> > 
> > 
> > $emp_email is being posted to the form.  Any ideas why this is being ignored?
> > 
> > dan
> 
> 
> -- 
> 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] eregi problems

2002-07-04 Thread Justin French

Dan,

I'll give you a little piece of advise that was given to me a little while
back on this list:

Go to http://www.killersoft.com/ and grab a copy of the validateEmailFormat
program.


PHP4 translation of Jeffrey E.F. Friedl's definitive Email Regex Program
from O'Reilly's Mastering Regular Expressions.  This function is used to
confirm if an e-mail address adheres to the RFC 822 specification for
internet email addresses.


Rather than trying re-invent the wheel, why not use something that conforms
closely to specs, and is widely accepted by many development groups.


All you'll have to do is something like (function names and filenames may
not be right):

please enter a valid email address";
}
?>


Side topic:  of course, you aren't checking for a valid email address at
all, your checking to see if the email address LOOKS valid.  You're not
checking to see if the address is attached to an email box, or furthermore
if there's anyone at the other end to open/read your email... you're just
validating the appearance of the address to fall within RFC 822 specs.

Subsequently [EMAIL PROTECTED] and [EMAIL PROTECTED]
will both return valid.


The only way to ensure an email address is truely valid is to send an email
to it, and have them respond... indicating that the address is linked to an
email box and furthermore, someone opened the email, read it, and responded.

Even then, this could be done by a robot I guess.


Justin French

Creative Director
http://Indent.com.au





on 05/07/02 12:23 AM, dan radom ([EMAIL PROTECTED]) wrote:

> I've got a form that's posted to a php page where I'm attempting to validate a
> field contains a valid email address.  The eregi below seems to be totally
> ignored...
> 
> if (eregi("^[a-z0-9\._-]+@[a-z0-9\._-]+$", $emp_email)) {
> echo "please enter a valid email address";
> exit;
> }
> 
> 
> $emp_email is being posted to the form.  Any ideas why this is being ignored?
> 
> dan


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




Re: [PHP] eregi not working

2002-06-07 Thread Jason Wong

On Saturday 08 June 2002 10:48, Robert Packer wrote:
> Can someone tell me why this isn't working? To me it say open the file,
> read it, stick into a variable, close the file. Then search that variable
> (the file) and look for the eregi statements. Can someone tell me why this
> only gets the first instance of what I'm searching for? Thanks a bunch.
>
> #!/usr/bin/php -q
>   $site = "proxy.html";
>  $open = fopen($site, "r");
>  $contents= fread($open,filesize($site));
>  fclose($open);
>   $search=eregi("[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}",
> $contents,$array);
>   echo $array[0];
>   echo $array[1];
>   echo $array[2];
> ?>

It looks like you're trying to match IP addresses? In which case shouldn't you 
have "echo $array[3];" as well? 

Anyway that's besides the point, what is the format of your file?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
I've got a bad feeling about this.
*/


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




Re: [PHP] eregi() against a binary file?

2002-05-29 Thread Miguel Cruz

According to the manual, the ereg functions are not binary safe. The 
superior-in-every-way preg functions are. Perhaps you could try using 
preg_grep instead.

$result = preg_grep('/' . preg_quote($imagename) . '/', $file);

You may find that strstr or something is even simpler.

miguel

On Tue, 28 May 2002, Kevin Stone wrote:
> I'm trying to match file names associated with a 3DS file (a 3DS file is a
> common 3D file format).  The file is binary by nature but as you can clearly
> see in the dump below the filenames themselves are stored as plain text.
> So I should be able to do a simple eregi() on the file and discover if the
> filename exists within that file or not, right?
> 
>   $imagename = "PYRSTN01.JPG";
> 
>  $path = "/home/placest/exchange/test.3ds";
>  $fp = fopen($path, "r");
>  if ($fp !== false)
>  {
>   $file = fread($fp, filesize($path));
>   fclose($fp);
> 
>   $result = eregi($imagename, $file);
>   if ($result == true)
>   {
>echo "FOUND IT";
>   }
>   else
>   {
>echo "COULD NOT FIND IT";
>   }
>  }
> ?>
> 
> Here's a snipplet of the file dump to the screen.  You can quite plainly see
> that "PYRSTN01.JPG" exists as text in this string.  Now if I copy a portion
> of this string and paste it into my code of course it works and echos 'found
> it'.  But if I perform the eregi() function on the raw string read directly
> from the file it prints 'could not find it'... why?  Isn't it the same exact
> thing?
> ---
> .0¡„ 0 Š ‡  €?¢30d£PYRSTN01.JPGQ£S£ 
> €?@vBox01AjAhƒ:oƒ:oƒ.
> ---
> 
> To be honest I don't know or even care about the difference between ASCII
> and BINARY.  In this case all I want to do is locate the plain text,
> "PYRSTN01.JPG" within the 3DS file string.  But clearly I'm missing some
> vital bit of information or there's something I don't understand about binay
> strings being interpreted as ASCII?  Anyone know how I can make this work?
> 
> Much thanks,
> -Kevin
> 
> 
> 


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




Re: [PHP] eregi(mail)

2002-05-21 Thread Miguel Cruz

On Tue, 21 May 2002, Denis L. Menezes wrote:
> I use the following code, but it does not work. Is there something wrong?
> 
> If
> (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a
> -z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
> $email_address))

One problem (syntax issues aside) is that it doesn't seem to be checking
for anything remotely similar to a valid email address.

Here's what we use. Not 100% perfect but closer than most, I think:

function validate_email ($addr)
{
  return

preg_match('/^[^\'"\s,;]+@([a-z0-9]+[a-z0-9\-]*\.)+[a-z0-9]+[a-z0-9\-]*[a-z0-9]+$/i',
  trim($addr)));
}

miguel


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




Re: [PHP] eregi(mail)

2002-05-21 Thread Denis L. Menezes

Hello friends,

I use the following code, but it does not work. Is there something wrong?

If
(ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a
-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
$email_address))
){
  Print ("Sorry, the email address seems to be invalid.");
  exit;
  }

Please help.
Denis
- Original Message -
From: "Steve Buehler" <[EMAIL PROTECTED]>
To: "Kevin Stone" <[EMAIL PROTECTED]>
Cc: "PHP" <[EMAIL PROTECTED]>
Sent: Saturday, May 11, 2002 2:45 AM
Subject: Re: [PHP] eregi(mail)


> Either Google is wrong (probably) or they are now allowing things like
> spaces into an email address.  There are actually several things that are
> not allowed in a standard email address.  Here is the code that I use.
>
ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-
z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
> $subarray))
> I am honestly not sure where I got this code, but it has always worked for
> me and I have not found any YET that are good address that this kills.  I
> have also not found any bad ones YET that this lets through (unless the
> domain or user doesn't exist, of course).
>
> Steve
>
> At 01:26 PM 5/10/2002, you wrote:
> >I had always been suspicious about email validators so I did a big long
> >search on Google about standard address formats.  It turns out that aside
> >from the @ symbol emails have no standard format whatsoever.  So
ereg('@',
> >$email) is really the only functional email validator.
> >
> >You also have to think about what kind of email validation you need.  Do
you
> >really need to control the format of the emails being stored in your
> >database?  Or do you need to control the validity of the emails being
stored
> >in your database?  There is a big difference.  A valid email address
isn't
> >necessarily one that is formated in the way you expect.  It is one that
is
> >active and can be mailed to.  There are a number of techniques you can
use
> >to determine that.
> >
> >Well.. anyway sorry for going off on a tangent there.  In your search for
an
> >email validator you got a bit more information than you expected.  I hope
it
> >was useful in some tiny miniscule sort of way.  :)
> >
> >--
> >Kevin Stone
> >[EMAIL PROTECTED]
> >
> >
> >- Original Message -
> >From: "Analysis & Solutions" <[EMAIL PROTECTED]>
> >To: "PHP List" <[EMAIL PROTECTED]>
> >Sent: Friday, May 10, 2002 10:59 AM
> >Subject: Re: [PHP] eregi(mail)
> >
> >
> > > Hi Liam:
> > >
> > > On Fri, May 10, 2002 at 09:48:58AM -0700, Liam Gibbs wrote:
> > > > Does anyone have a decent eregi statement for
> > > > validating e-mail addresses?
> > >
> > > eregi('^[a-z0-9_.=+-]+@([a-z0-9-]+\.)+([a-z]{2,6})$', $Email);
> > >
> > > Enjoy,
> > >
> > > --Dan
> > >
> > > --
> > >PHP classes that make web design easier
> > > SQL Solution  |   Layout Solution   |  Form Solution
> > > sqlsolution.info  | layoutsolution.info |  formsolution.info
> > >  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
> > >  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
> > >
> > > --
> > > 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


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




Re: [PHP] eregi(mail)

2002-05-16 Thread Liam Gibbs

Thanks to all who helped out with the eregi(mail)
stuff. I got my problem solved, and on top of that,
there were some bugs that I found in the code. Thanks
again to everyone.


__
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

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




Re: [PHP] eregi(mail)

2002-05-10 Thread Miguel Cruz

On Fri, 10 May 2002, Kevin Stone wrote:
> As we all know ARPA is thet university network, funded by the government
> to build an information infrastructure that eventually became the
> internet we have today.  But the standards for text messaging within the
> ARPA net have been added to over the years in order to accomodate ever
> expanding requirments.

Yes, and those changes are codified into new RFCs which eventually become
standards. By all means have a look at RFC 2822 which, if passed into use,
will obsolete 822.

> For example I have read that a valid email needn't necessarily require
> anything before the @ symbol.  The ARPA RFC specifically states that it
> does.  But <[EMAIL PROTECTED]> can be just as valid as <@foo.bar.com>  if the the
> domain resolves and the server is setup to parse from a catch all account
> named ''.  Is this not true?

Sure, and if a web server is set up to respond to a request like:

   SPLEARGH www.boogermax.com/greebles ? 888 *** 3424235667

then web browsers could send it and get something in return, but it 
doesn't mean it's a valid HTTP request.

> If this is true then eregi(/^[a-z0-9]+/, $email ) wouldn't necessarily be
> valid.  We could then say that eregi(/^[a-z0-9]*/, $email) is pointless
> becuase if nothing has to be there then there isn't any reason to look for
> it.  And thus we return to the original assertion that ereg('@', $email) is
> the only way to know that the string is a properly formated email address.

"Properly formatted email address" is a term whose meaning derives from a
prescriptive, rather than descriptive, definition. A properly-formatted 
email address is one which has been properly formatted in accordance with 
the rules governing mail addressing, and nothing any more arbitrary than 
that.

> So why even validate that format beyond the most basic rules (@, length, and
> invalid characters)?   The result of which is useless, unless the address is
> sendable, in which case the string format is irrelevant.

Why even look for an @ sign then? I can address a message to 'mnc' and it
will arrive just fine - within my zone of control.

The reason that we use standards is to ensure that hardware and software 
from various vendors can communicate with each other without unexpected 
results. As soon as you start giving that up, you subdivide the internet 
into smaller zones of mutual compatibility. About 99.9% of the time, there 
is no constructive reason for doing it. Given the flexibility already 
allowed in email addressesing, I certainly don't see this as one of the 
exceptions.

miguel


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




RE: [PHP] eregi(mail)

2002-05-10 Thread Nathan Cassano


This is what I have used.




Here is an excellent article on Regular Expressions.

Learning to Use Regular Expressions by Example
http://www.phpbuilder.com/columns/dario19990616.php3


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




Re: [PHP] eregi(mail)

2002-05-10 Thread Kevin Stone

As we all know ARPA is thet university network, funded by the government to
build an information infrastructure that eventually became the internet we
have today.  But the standards for text messaging within the ARPA net have
been added to over the years in order to accomodate ever expanding
requirments.

For example I have read that a valid email needn't necessarily require
anything before the @ symbol.  The ARPA RFC specifically states that it
does.  But <[EMAIL PROTECTED]> can be just as valid as <@foo.bar.com>  if the the
domain resolves and the server is setup to parse from a catch all account
named ''.  Is this not true?

If this is true then eregi(/^[a-z0-9]+/, $email ) wouldn't necessarily be
valid.  We could then say that eregi(/^[a-z0-9]*/, $email) is pointless
becuase if nothing has to be there then there isn't any reason to look for
it.  And thus we return to the original assertion that ereg('@', $email) is
the only way to know that the string is a properly formated email address.

So why even validate that format beyond the most basic rules (@, length, and
invalid characters)?   The result of which is useless, unless the address is
sendable, in which case the string format is irrelevant.
-Kevin

- Original Message -
From: "Miguel Cruz" <[EMAIL PROTECTED]>
To: "Kevin Stone" <[EMAIL PROTECTED]>
Cc: "PHP-general" <[EMAIL PROTECTED]>
Sent: Friday, May 10, 2002 12:30 PM
Subject: Re: [PHP] eregi(mail)


> On Fri, 10 May 2002, Kevin Stone wrote:
> > I had always been suspicious about email validators so I did a big long
> > search on Google about standard address formats.  It turns out that
aside
> > from the @ symbol emails have no standard format whatsoever.  So
ereg('@',
> > $email) is really the only functional email validator.
>
> There is a format. See:
>
>http://www.merit.edu/internet/documents/rfc/rfc0822.txt
>
> miguel
>
>



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




Re: [PHP] eregi(mail)

2002-05-10 Thread Steve Buehler

To tell you the truth, I can't read it.

Steve

At 01:32 PM 5/10/2002, Miguel Cruz wrote:
>On Fri, 10 May 2002, Steve Buehler wrote:
> > 
> 
>if(ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
> 
>
>
>If I'm reading it correctly, this will let invalid addresses through. The
>domain component (after the @ sign) can only contain a-zA-Z0-9\.\-
>
>miguel
>
>
>--
>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] eregi(mail)

2002-05-10 Thread Steve Buehler

Either Google is wrong (probably) or they are now allowing things like 
spaces into an email address.  There are actually several things that are 
not allowed in a standard email address.  Here is the code that I use.
ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
 
$subarray))
I am honestly not sure where I got this code, but it has always worked for 
me and I have not found any YET that are good address that this kills.  I 
have also not found any bad ones YET that this lets through (unless the 
domain or user doesn't exist, of course).

Steve

At 01:26 PM 5/10/2002, you wrote:
>I had always been suspicious about email validators so I did a big long
>search on Google about standard address formats.  It turns out that aside
>from the @ symbol emails have no standard format whatsoever.  So ereg('@',
>$email) is really the only functional email validator.
>
>You also have to think about what kind of email validation you need.  Do you
>really need to control the format of the emails being stored in your
>database?  Or do you need to control the validity of the emails being stored
>in your database?  There is a big difference.  A valid email address isn't
>necessarily one that is formated in the way you expect.  It is one that is
>active and can be mailed to.  There are a number of techniques you can use
>to determine that.
>
>Well.. anyway sorry for going off on a tangent there.  In your search for an
>email validator you got a bit more information than you expected.  I hope it
>was useful in some tiny miniscule sort of way.  :)
>
>--
>Kevin Stone
>[EMAIL PROTECTED]
>
>
>- Original Message -
>From: "Analysis & Solutions" <[EMAIL PROTECTED]>
>To: "PHP List" <[EMAIL PROTECTED]>
>Sent: Friday, May 10, 2002 10:59 AM
>Subject: Re: [PHP] eregi(mail)
>
>
> > Hi Liam:
> >
> > On Fri, May 10, 2002 at 09:48:58AM -0700, Liam Gibbs wrote:
> > > Does anyone have a decent eregi statement for
> > > validating e-mail addresses?
> >
> > eregi('^[a-z0-9_.=+-]+@([a-z0-9-]+\.)+([a-z]{2,6})$', $Email);
> >
> > Enjoy,
> >
> > --Dan
> >
> > --
> >PHP classes that make web design easier
> > SQL Solution  |   Layout Solution   |  Form Solution
> > sqlsolution.info  | layoutsolution.info |  formsolution.info
> >  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
> >  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
> >
> > --
> > 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] eregi(mail)

2002-05-10 Thread Analysis & Solutions

Folks:

On Fri, May 10, 2002 at 01:27:45PM -0500, Steve Buehler wrote:
> 
> 
>if(ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
> 
> $subarray)){

Those characters don't conform to the RFC.

Miguel, thanks for posting the RFC (in the prior email).  That's what I based my ereg 
on (as shown in yet another earlier email).

Enjoy,

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




Re: [PHP] eregi(mail)

2002-05-10 Thread Miguel Cruz

On Fri, 10 May 2002, Steve Buehler wrote:
> 
>if(ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
> 

If I'm reading it correctly, this will let invalid addresses through. The
domain component (after the @ sign) can only contain a-zA-Z0-9\.\-

miguel


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




Re: [PHP] eregi(mail)

2002-05-10 Thread Miguel Cruz

On Fri, 10 May 2002, Kevin Stone wrote:
> I had always been suspicious about email validators so I did a big long
> search on Google about standard address formats.  It turns out that aside
> from the @ symbol emails have no standard format whatsoever.  So ereg('@',
> $email) is really the only functional email validator.

There is a format. See:

   http://www.merit.edu/internet/documents/rfc/rfc0822.txt

miguel


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




Re: [PHP] eregi(mail)

2002-05-10 Thread Steve Buehler


function check_input($array){
 global $HTTP_REFERER;
 $valid = 1;
 if(gettype($array)=="array") {
 while (list($index, $subarray) = each($array) ) {
 if(ereg("required_", $index) && (($subarray == "") 
|| ($subarray == " "))) {
 $index = ereg_replace("required_", " ", 
$index);
 $index = ereg_replace("_", " ", $index);
 echo"
There is a problem with your submission. The field $index is required, 
please go back and fill in the form. (Or press the back button on your browser)
";
 $valid = 0;
 return 0;
 exit;
 }elseif(eregi("email", $index)){
 
if(ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
 
$subarray)){
 $email_check = 1;
 }else{
 $index = ereg_replace("required_", 
" ", $index);
 echo"
There is a problem with your submission. The E-mail address you provided, 
$subarray, does not appear to be valid, please go back and give a valid 
address. (Or press the back button on your browser)
";
 return 0;
 exit;
 }
 }else{
 $email_check = 10;
 }
 }
 if($valid == "1" && ($email_check == "1" || $email_check 
== "10")) {
 return 1;
 }else{
 return 0;
 }
 }
}



At 11:48 AM 5/10/2002, you wrote:
>Does anyone have a decent eregi statement for
>validating e-mail addresses? I've tried the ones on
>the site, but there seems to be small bugs with each
>of them. They tell me that [EMAIL PROTECTED] is an
>invalid e-mail address.
>
>__
>Do You Yahoo!?
>Yahoo! Shopping - Mother's Day is May 12th!
>http://shopping.yahoo.com
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] eregi(mail)

2002-05-10 Thread Kevin Stone

I had always been suspicious about email validators so I did a big long
search on Google about standard address formats.  It turns out that aside
from the @ symbol emails have no standard format whatsoever.  So ereg('@',
$email) is really the only functional email validator.

You also have to think about what kind of email validation you need.  Do you
really need to control the format of the emails being stored in your
database?  Or do you need to control the validity of the emails being stored
in your database?  There is a big difference.  A valid email address isn't
necessarily one that is formated in the way you expect.  It is one that is
active and can be mailed to.  There are a number of techniques you can use
to determine that.

Well.. anyway sorry for going off on a tangent there.  In your search for an
email validator you got a bit more information than you expected.  I hope it
was useful in some tiny miniscule sort of way.  :)

--
Kevin Stone
[EMAIL PROTECTED]


- Original Message -
From: "Analysis & Solutions" <[EMAIL PROTECTED]>
To: "PHP List" <[EMAIL PROTECTED]>
Sent: Friday, May 10, 2002 10:59 AM
Subject: Re: [PHP] eregi(mail)


> Hi Liam:
>
> On Fri, May 10, 2002 at 09:48:58AM -0700, Liam Gibbs wrote:
> > Does anyone have a decent eregi statement for
> > validating e-mail addresses?
>
> eregi('^[a-z0-9_.=+-]+@([a-z0-9-]+\.)+([a-z]{2,6})$', $Email);
>
> Enjoy,
>
> --Dan
>
> --
>PHP classes that make web design easier
> SQL Solution  |   Layout Solution   |  Form Solution
> sqlsolution.info  | layoutsolution.info |  formsolution.info
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
>
> --
> 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] eregi(mail)

2002-05-10 Thread Miguel Cruz

On Fri, 10 May 2002, Liam Gibbs wrote:
> Does anyone have a decent eregi statement for
> validating e-mail addresses? I've tried the ones on
> the site, but there seems to be small bugs with each
> of them. They tell me that [EMAIL PROTECTED] is an
> invalid e-mail address.

Well, it currently is an invalid email address (NXDOMAIN fdsf.net).
Perhaps the functions you've tried are doing lookups on the domain portion
of the address?

miguel


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




Re: [PHP] eregi(mail)

2002-05-10 Thread Analysis & Solutions

Hi Liam:

On Fri, May 10, 2002 at 09:48:58AM -0700, Liam Gibbs wrote:
> Does anyone have a decent eregi statement for
> validating e-mail addresses?

eregi('^[a-z0-9_.=+-]+@([a-z0-9-]+\.)+([a-z]{2,6})$', $Email);

Enjoy,

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




Re: [PHP] eregi

2002-05-02 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Miguel Cruz) wrote:

> On Thu, 2 May 2002, CC Zona wrote:
> > [EMAIL PROTECTED] (Miguel Cruz) wrote:
> >> preg_match("/{$start}(.*?)end/", $rf, my_var);
> > 
> > Leave out the braces.
> 
> Don't they get removed by the parser's handling of "double-quoted" strings 
> long before anything makes it to preg_match()? 
> 
> I almost always use the braces when inserting variables inside string 
> literals, just to avoid any chance of ambiguity.

There's no ambiguity here since parentheses aren't legal in variable names, 
so the curly braces are just excess.  Given the braces' significant as 
special regex characters, it can be a confusing distraction in this 
context, especially for newbies trying to grasp simply regex syntax.  
Better to save the braces for where they're needed to tell the parser or 
programmer how to interpret ambiguous code.

-- 
CC

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




Re: [PHP] eregi

2002-05-02 Thread Miguel Cruz

On Thu, 2 May 2002, CC Zona wrote:
> [EMAIL PROTECTED] (Miguel Cruz) wrote:
>> preg_match("/{$start}(.*?)end/", $rf, my_var);
> 
> Leave out the braces.

Don't they get removed by the parser's handling of "double-quoted" strings 
long before anything makes it to preg_match()? 

I almost always use the braces when inserting variables inside string 
literals, just to avoid any chance of ambiguity.

miguel


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




Re: [PHP] eregi

2002-05-02 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Miguel Cruz) wrote:

> On Thu, 2 May 2002, Fredrik Arild Takle wrote:
> > eregi("$start(.*)end", $rf, $my_var);
> > 
> > And I want it to stop at the first presedence of $end, not the last (thats
> > what this is doing).
> 
> Try preg, which is faster and gives you more control (here the ? 
> munificence operator).
> 
> preg_match("/{$start}(.*?)end/", $rf, my_var);

Leave out the braces.

preg_match("/$start(.*?)end/", $rf, my_var);
  -or-
preg_match("/$start(.*)end/U", $rf, my_var);


(And make sure the value of $start either doesn't have any regex special 
chars, or is using them intentionally, or has them escaped 
.)

-- 
CC

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




Re: [PHP] eregi

2002-05-02 Thread Miguel Cruz

On Thu, 2 May 2002, Fredrik Arild Takle wrote:
> eregi("$start(.*)end", $rf, $my_var);
> 
> And I want it to stop at the first presedence of $end, not the last (thats
> what this is doing).

Try preg, which is faster and gives you more control (here the ? 
munificence operator).

preg_match("/{$start}(.*?)end/", $rf, my_var);

miguel


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




Re: [PHP] eregi() problem

2002-04-21 Thread Miguel Cruz

On Mon, 22 Apr 2002, Gregor Jaksa wrote:
> if (!eregi("^[[:alpha:]]$", $HTTP_POST_VARS["vpis_ime"]))
>   echo "wrong char";
> 
> why does this always return "wrong char" no matter what value is in vpis_ime
> ... i tried "blah", "242234" "bla242h" .. every single time i get "wrong
> char". im using PHP 4.1.2

The only thing that will match that regex is a single alpha character.

Try "^[[:alpha:]]+$" (I added a plus) to match one or more.

miguel


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




Re: [PHP] eregi() problem

2002-04-21 Thread Danny Shepherd

Try:

if (!eregi('^[a-z_\-]{0,}$', $_POST['vpis_ime']))
  echo "wrong char";

That'll sort it for everything except [ and ], which I can't find any way of
checking for :-( Anyone else have any ideas?

HTH anyway.

Danny.

- Original Message -
From: "Gregor Jaksa" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 22, 2002 1:04 AM
Subject: [PHP] eregi() problem


> if (!eregi("^[[:alpha:]]$", $HTTP_POST_VARS["vpis_ime"]))
>   echo "wrong char";
>
> why does this always return "wrong char" no matter what value is in
vpis_ime
> ... i tried "blah", "242234" "bla242h" .. every single time i get "wrong
> char". im using PHP 4.1.2
>
> basicly is what i want is to check string if it contains only charaters
from
> a to z and chars _ - [ ] . Can somebody write me a working function ?
>
> thx in advance


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




Re: [PHP] eregi() problems...

2002-04-16 Thread Michael Virnstein

the rest seems ok to me, if you search for files with e.g hello_.jpg as
name

"Michael Virnstein" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> eregi('_[0-9]{4}.jpg$', $file_name)
>
> should be
>
> eregi('_[0-9]{4}\.jpg$', $file_name)
>
> . is a spcial character(means every character) and has to be backslashed
if
> you want it's normal meaning
>
>
> "Jas" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > I must be doing something wrong, for that solution did not work.
> >
> > "Robert Cummings" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > jas wrote:
> > > >
> > > > // second selection for main image on main page
> > > > $dir_name = "/path/to/images/directory/";
> > > > $dir = opendir($dir_name);
> > > > $file_lost .= " > NAME=\"ad01\">
> > > > ";
> > > >  while ($file_names = readdir($dir)) {
> > > >   if ($file_names != "." && $file_names !=".." &&
> > eregi('_[0-9]{4}.jpg$',
> > > > $file_name)) {
> > > >   $file_lost .= " > > > NAME=\"$file_names\">$file_names";
> > > >   }
> > > >  }
> > > >  $file_lost .= " NAME=\"submit\"
> > > > VALUE=\"select\">";
> > > >  closedir($dir);
> > > >
> > > > My problem is with the eregi() function to filter out files without
> the
> > > > following criteria *_.jpg, it must have an underscore followed
by
> 4
> > > > numbers and then ending in .jpg file extension.  I have tried a few
> > > > different methods to try and get this to work however I think I am
> > missing
> > > > something.  All of the documentation I have read on php.net states
> that
> > this
> > > > string should work as is... I have checked the contents of the
> directory
> > and
> > > > I only have files of these two types...
> > > > filename_logo.jpg
> > > > filename_0103.jpg
> > > > Could anyone enlighten me on how this is not working?
> > > > Thanks in advance,
> > >
> > > I hope I'm reading right... it seems you want to filter OUT files with
> > > the extension '_.jpg' the above check appears to be filtering out
> > > everything BUT these files. I think you want the following check:
> > >
> > > if( $file_names != "."
> > > &&
> > > $file_names !=".."
> > > &&
> > > !eregi( '_[0-9]{4}\.jpg$', $file_name) )
> > >
> > > Cheers,
> > > Rob.
> > > --
> > > .-.
> > > | Robert Cummings |
> > > :-`.
> > > | Webdeployer - Chief PHP and Java Programmer  |
> > > :--:
> > > | Mail  : mailto:[EMAIL PROTECTED] |
> > > | Phone : (613) 731-4046 x.109 |
> > > :--:
> > > | Website : http://www.webmotion.com   |
> > > | Fax : (613) 260-9545 |
> > > `--'
> >
> >
>
>



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




Re: [PHP] eregi() problems...

2002-04-16 Thread Michael Virnstein

eregi('_[0-9]{4}.jpg$', $file_name)

should be

eregi('_[0-9]{4}\.jpg$', $file_name)

. is a spcial character(means every character) and has to be backslashed if
you want it's normal meaning


"Jas" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I must be doing something wrong, for that solution did not work.
>
> "Robert Cummings" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > jas wrote:
> > >
> > > // second selection for main image on main page
> > > $dir_name = "/path/to/images/directory/";
> > > $dir = opendir($dir_name);
> > > $file_lost .= " NAME=\"ad01\">
> > > ";
> > >  while ($file_names = readdir($dir)) {
> > >   if ($file_names != "." && $file_names !=".." &&
> eregi('_[0-9]{4}.jpg$',
> > > $file_name)) {
> > >   $file_lost .= " > > NAME=\"$file_names\">$file_names";
> > >   }
> > >  }
> > >  $file_lost .= " > > VALUE=\"select\">";
> > >  closedir($dir);
> > >
> > > My problem is with the eregi() function to filter out files without
the
> > > following criteria *_.jpg, it must have an underscore followed by
4
> > > numbers and then ending in .jpg file extension.  I have tried a few
> > > different methods to try and get this to work however I think I am
> missing
> > > something.  All of the documentation I have read on php.net states
that
> this
> > > string should work as is... I have checked the contents of the
directory
> and
> > > I only have files of these two types...
> > > filename_logo.jpg
> > > filename_0103.jpg
> > > Could anyone enlighten me on how this is not working?
> > > Thanks in advance,
> >
> > I hope I'm reading right... it seems you want to filter OUT files with
> > the extension '_.jpg' the above check appears to be filtering out
> > everything BUT these files. I think you want the following check:
> >
> > if( $file_names != "."
> > &&
> > $file_names !=".."
> > &&
> > !eregi( '_[0-9]{4}\.jpg$', $file_name) )
> >
> > Cheers,
> > Rob.
> > --
> > .-.
> > | Robert Cummings |
> > :-`.
> > | Webdeployer - Chief PHP and Java Programmer  |
> > :--:
> > | Mail  : mailto:[EMAIL PROTECTED] |
> > | Phone : (613) 731-4046 x.109 |
> > :--:
> > | Website : http://www.webmotion.com   |
> > | Fax : (613) 260-9545 |
> > `--'
>
>



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




Re: [PHP] eregi() problems...

2002-04-15 Thread jas

I must be doing something wrong, for that solution did not work.

"Robert Cummings" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> jas wrote:
> >
> > // second selection for main image on main page
> > $dir_name = "/path/to/images/directory/";
> > $dir = opendir($dir_name);
> > $file_lost .= "
> > ";
> >  while ($file_names = readdir($dir)) {
> >   if ($file_names != "." && $file_names !=".." &&
eregi('_[0-9]{4}.jpg$',
> > $file_name)) {
> >   $file_lost .= " > NAME=\"$file_names\">$file_names";
> >   }
> >  }
> >  $file_lost .= " > VALUE=\"select\">";
> >  closedir($dir);
> >
> > My problem is with the eregi() function to filter out files without the
> > following criteria *_.jpg, it must have an underscore followed by 4
> > numbers and then ending in .jpg file extension.  I have tried a few
> > different methods to try and get this to work however I think I am
missing
> > something.  All of the documentation I have read on php.net states that
this
> > string should work as is... I have checked the contents of the directory
and
> > I only have files of these two types...
> > filename_logo.jpg
> > filename_0103.jpg
> > Could anyone enlighten me on how this is not working?
> > Thanks in advance,
>
> I hope I'm reading right... it seems you want to filter OUT files with
> the extension '_.jpg' the above check appears to be filtering out
> everything BUT these files. I think you want the following check:
>
> if( $file_names != "."
> &&
> $file_names !=".."
> &&
> !eregi( '_[0-9]{4}\.jpg$', $file_name) )
>
> Cheers,
> Rob.
> --
> .-.
> | Robert Cummings |
> :-`.
> | Webdeployer - Chief PHP and Java Programmer  |
> :--:
> | Mail  : mailto:[EMAIL PROTECTED] |
> | Phone : (613) 731-4046 x.109 |
> :--:
> | Website : http://www.webmotion.com   |
> | Fax : (613) 260-9545 |
> `--'



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




Re: [PHP] eregi() problems...

2002-04-15 Thread Robert Cummings

jas wrote:
> 
> // second selection for main image on main page
> $dir_name = "/path/to/images/directory/";
> $dir = opendir($dir_name);
> $file_lost .= "
> ";
>  while ($file_names = readdir($dir)) {
>   if ($file_names != "." && $file_names !=".." && eregi('_[0-9]{4}.jpg$',
> $file_name)) {
>   $file_lost .= " NAME=\"$file_names\">$file_names";
>   }
>  }
>  $file_lost .= " VALUE=\"select\">";
>  closedir($dir);
> 
> My problem is with the eregi() function to filter out files without the
> following criteria *_.jpg, it must have an underscore followed by 4
> numbers and then ending in .jpg file extension.  I have tried a few
> different methods to try and get this to work however I think I am missing
> something.  All of the documentation I have read on php.net states that this
> string should work as is... I have checked the contents of the directory and
> I only have files of these two types...
> filename_logo.jpg
> filename_0103.jpg
> Could anyone enlighten me on how this is not working?
> Thanks in advance,

I hope I'm reading right... it seems you want to filter OUT files with
the extension '_.jpg' the above check appears to be filtering out
everything BUT these files. I think you want the following check:

if( $file_names != "."
&&
$file_names !=".."
&&
!eregi( '_[0-9]{4}\.jpg$', $file_name) )

Cheers,
Rob.
-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

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




Re: [PHP] eregi()

2002-03-19 Thread Rénald CASAGRAUDE

Vlad Kulchitski wrote:
> 
> Hi,
> 
> Can any1 send a small script of how to valiade a username using eregi().
> 
> I want username to consist only a-zA-Z1-0, "_", and "-"
> 
> I can't get it to work correctly

$pattern = "[a-zA-Z0-9_\-]+";
this is meaning :
One word containing a-z or A-Z or 0-9 or "_" or "-" with a length of
minimum 1 character !

Regular expression is not so difficult !
Check the php documentation !
http://www.php.net/manual/en/ref.regex.php

R.

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




Re: [PHP] eregi, ereg or smth. else???

2002-02-26 Thread bvr


You don't need regular expressions for this.

To match case insensitive, just upper or lower case both strings
and use strpos() to find an occurence. Now you allready have the
position of the match it'll be easy to get that part of the string.

I suggest you substr() it into 3 parts and put the  and  in between.

bvr.

On Tue, 26 Feb 2002 11:50:31 +0200 (EET), Kristjan Kanarik wrote:

>I've never had time to get into those ereg, eregi etc. functions, and now
>I am affraid I probably need to use them. Here is the problem I need to
>solve:
>
>I have a string (lead of an article), about 200-250 characters long. And
>then I do have a search query - variable $q
>
>Now, what I'd like to do is to check wheter this string contains the
>search query or not. Case sensitivity is not important, so if the $q
>equals to 'SoMeThInG', the script would find also 'sOmEtHiNg'. If the
>string contains the search query, I'd like to display 100 characters of
>this string (lead) - the search query should be in the middle of this
>substring and within BOLD and /BOLD tags.
>
>If the search query is in the beginning of the string, say at position 10,
>then I'd like to display 100 first characters of the string... and if it
>is say at position 230 (250 chars together), it should display the string
>starting at position 250-100.
>
>I know it shouldn't be difficult to do, but I am kind of stuck and
>frustrated.
>
>TIA,
>Kristjan
>
>P.S. Pls. CC me as well - I am only in the digest.
>
>
>-- 
>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] eregi

2002-02-08 Thread DL Neil

Hello John

> I'm using eregi to print out parts of a text file, and I was just wondering 
> how you get the code to print out a newline as it appears in the file.


Not quite sure what eregi has to do with it - perhaps I'm missing something.

Would the nl2br function help?

=dn



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




Re: [PHP] eregi and alfa numeric characters.

2002-01-11 Thread Jimmy

Hi Sait,

> no characters except for the followings will not be allowed.
> 0-9 a-z A-Z   ~ @ # $ %  ( ) _  - +  =  [ ]  { }  < ? >

if ( ereg("[^0-9a-zA-Z\_\-]", $user_input) ) {
  //invalid char detected
}
else {
  //input contain only allowed char
}

just add all your valid char in the pattern, and dont forget
to escape the char which has special meaning in regex.

--
Jimmy

Money is what you make it - a servant or a master


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eregi

2001-10-02 Thread mike cullerton

on 10/2/01 8:51 AM, CC Zona at [EMAIL PROTECTED] wrote:

> In article <[EMAIL PROTECTED]>,
> [EMAIL PROTECTED] (Mike Cullerton) wrote:
> 
>> eregi("^[a-z0-9_\-]+$",$string)
>> 
>> notice that i had to escape the dash with a backslash
> 
> Are you sure?  'Cuz AFAIK, escaping shouldn't be necessary on a hyphen
> which is the last char (or, IIRC, the first) of a character class.

cool. so, are you saying eregi("^[-a-z0-9_]+$",$string) should work?

thanks,
mike


 -- mike cullerton



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eregi

2001-10-02 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Mike Cullerton) wrote:

> eregi("^[a-z0-9_\-]+$",$string)
> 
> notice that i had to escape the dash with a backslash

Are you sure?  'Cuz AFAIK, escaping shouldn't be necessary on a hyphen 
which is the last char (or, IIRC, the first) of a character class.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eregi

2001-10-01 Thread mike cullerton

i realize a solution using strspn/strcspn was offered, but you asked for
eregi :)

anyway, i use ereg, but i think this should work

eregi("^[a-z0-9_\-]+$",$string)

notice that i had to escape the dash with a backslash

the plus sign forces atleast one character. you can use {x,y} in place of
the plus to force atleast x characters but no more than y characters.

mike

on 10/1/01 4:53 PM, Tim Ballantine at [EMAIL PROTECTED] wrote:

> Thankyou...
> 
> I should have made it clearer that I did want to use only the legal
> characters to compare the string by.
> 
> Tim
> 
> "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> Well, either you need to know the valid chars or the invalid ones.  Make
>> up your mind and use strspn() or strcspn() appropriately.
>> 
>> -Rasmus
>> 
>> On Mon, 1 Oct 2001, Tim Ballantine wrote:
>> 
>>> "Returns the length of the initial segment of str1 which does not
> contain
>>> any of the characters in str2."
>>> 
>>> I realise that i could see if this matches with the length of the entire
>>> word, and is there a way to get it to compare the word by the legal
>>> characters, because the amount of illegal symbols, including different
>>> language symbols (french for example) will be too high for me to list.
>>> 
>>> Tim
>>> 
>>> "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
>>> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Huh?  You better read that documentation page again.  You only need to
 list the illegal symbols.  And what do you mean by length?
 
 -Rasmus
 
 On Mon, 1 Oct 2001, Tim Ballantine wrote:
 
> Is there anything which doesnt use length? And something like eregi,
>>> because
> it would be infeasible to list all of the symbols that a user could
> use,
>>> to
> compare a string by.
> 
> Tim
> 
> "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> See php.net/strcspn
>> 
>> On Mon, 1 Oct 2001, Tim Ballantine wrote:
>> 
>>> Hello,
>>> 
>>> Could anyone tell me how to eregi a word, to see if it only
> contains
> either
>>> numbers, letters, the "_" and the "-", so that any other symbol
> with
> call it
>>> invalid. For example, theres the word "expressio_n" that will be
>>> valid,
> but
>>> the word "express%^$-n" will be invalid.
>>> 
>>> Thankyou,
>>> 
>>> Tim
>>> 
>>> 
>>> 
>>> 
>> 
> 
> 
> 
> 
 
>>> 
>>> 
>>> 
>>> 
>> 
>> 
> 
> 


 -- mike cullerton



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eregi

2001-10-01 Thread Tim Ballantine

Thankyou...

I should have made it clearer that I did want to use only the legal
characters to compare the string by.

Tim

"Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Well, either you need to know the valid chars or the invalid ones.  Make
> up your mind and use strspn() or strcspn() appropriately.
>
> -Rasmus
>
> On Mon, 1 Oct 2001, Tim Ballantine wrote:
>
> > "Returns the length of the initial segment of str1 which does not
contain
> > any of the characters in str2."
> >
> > I realise that i could see if this matches with the length of the entire
> > word, and is there a way to get it to compare the word by the legal
> > characters, because the amount of illegal symbols, including different
> > language symbols (french for example) will be too high for me to list.
> >
> > Tim
> >
> > "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Huh?  You better read that documentation page again.  You only need to
> > > list the illegal symbols.  And what do you mean by length?
> > >
> > > -Rasmus
> > >
> > > On Mon, 1 Oct 2001, Tim Ballantine wrote:
> > >
> > > > Is there anything which doesnt use length? And something like eregi,
> > because
> > > > it would be infeasible to list all of the symbols that a user could
use,
> > to
> > > > compare a string by.
> > > >
> > > > Tim
> > > >
> > > > "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
> > > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > > See php.net/strcspn
> > > > >
> > > > > On Mon, 1 Oct 2001, Tim Ballantine wrote:
> > > > >
> > > > > > Hello,
> > > > > >
> > > > > > Could anyone tell me how to eregi a word, to see if it only
contains
> > > > either
> > > > > > numbers, letters, the "_" and the "-", so that any other symbol
with
> > > > call it
> > > > > > invalid. For example, theres the word "expressio_n" that will be
> > valid,
> > > > but
> > > > > > the word "express%^$-n" will be invalid.
> > > > > >
> > > > > > Thankyou,
> > > > > >
> > > > > > Tim
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
> >
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eregi

2001-10-01 Thread Rasmus Lerdorf

Well, either you need to know the valid chars or the invalid ones.  Make
up your mind and use strspn() or strcspn() appropriately.

-Rasmus

On Mon, 1 Oct 2001, Tim Ballantine wrote:

> "Returns the length of the initial segment of str1 which does not contain
> any of the characters in str2."
>
> I realise that i could see if this matches with the length of the entire
> word, and is there a way to get it to compare the word by the legal
> characters, because the amount of illegal symbols, including different
> language symbols (french for example) will be too high for me to list.
>
> Tim
>
> "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Huh?  You better read that documentation page again.  You only need to
> > list the illegal symbols.  And what do you mean by length?
> >
> > -Rasmus
> >
> > On Mon, 1 Oct 2001, Tim Ballantine wrote:
> >
> > > Is there anything which doesnt use length? And something like eregi,
> because
> > > it would be infeasible to list all of the symbols that a user could use,
> to
> > > compare a string by.
> > >
> > > Tim
> > >
> > > "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
> > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > See php.net/strcspn
> > > >
> > > > On Mon, 1 Oct 2001, Tim Ballantine wrote:
> > > >
> > > > > Hello,
> > > > >
> > > > > Could anyone tell me how to eregi a word, to see if it only contains
> > > either
> > > > > numbers, letters, the "_" and the "-", so that any other symbol with
> > > call it
> > > > > invalid. For example, theres the word "expressio_n" that will be
> valid,
> > > but
> > > > > the word "express%^$-n" will be invalid.
> > > > >
> > > > > Thankyou,
> > > > >
> > > > > Tim
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > >
> >
>
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eregi

2001-10-01 Thread Tim Ballantine

"Returns the length of the initial segment of str1 which does not contain
any of the characters in str2."

I realise that i could see if this matches with the length of the entire
word, and is there a way to get it to compare the word by the legal
characters, because the amount of illegal symbols, including different
language symbols (french for example) will be too high for me to list.

Tim

"Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Huh?  You better read that documentation page again.  You only need to
> list the illegal symbols.  And what do you mean by length?
>
> -Rasmus
>
> On Mon, 1 Oct 2001, Tim Ballantine wrote:
>
> > Is there anything which doesnt use length? And something like eregi,
because
> > it would be infeasible to list all of the symbols that a user could use,
to
> > compare a string by.
> >
> > Tim
> >
> > "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > See php.net/strcspn
> > >
> > > On Mon, 1 Oct 2001, Tim Ballantine wrote:
> > >
> > > > Hello,
> > > >
> > > > Could anyone tell me how to eregi a word, to see if it only contains
> > either
> > > > numbers, letters, the "_" and the "-", so that any other symbol with
> > call it
> > > > invalid. For example, theres the word "expressio_n" that will be
valid,
> > but
> > > > the word "express%^$-n" will be invalid.
> > > >
> > > > Thankyou,
> > > >
> > > > Tim
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
> >
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eregi

2001-10-01 Thread Rasmus Lerdorf

Huh?  You better read that documentation page again.  You only need to
list the illegal symbols.  And what do you mean by length?

-Rasmus

On Mon, 1 Oct 2001, Tim Ballantine wrote:

> Is there anything which doesnt use length? And something like eregi, because
> it would be infeasible to list all of the symbols that a user could use, to
> compare a string by.
>
> Tim
>
> "Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > See php.net/strcspn
> >
> > On Mon, 1 Oct 2001, Tim Ballantine wrote:
> >
> > > Hello,
> > >
> > > Could anyone tell me how to eregi a word, to see if it only contains
> either
> > > numbers, letters, the "_" and the "-", so that any other symbol with
> call it
> > > invalid. For example, theres the word "expressio_n" that will be valid,
> but
> > > the word "express%^$-n" will be invalid.
> > >
> > > Thankyou,
> > >
> > > Tim
> > >
> > >
> > >
> > >
> >
>
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eregi

2001-10-01 Thread Tim Ballantine

Is there anything which doesnt use length? And something like eregi, because
it would be infeasible to list all of the symbols that a user could use, to
compare a string by.

Tim

"Rasmus Lerdorf" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> See php.net/strcspn
>
> On Mon, 1 Oct 2001, Tim Ballantine wrote:
>
> > Hello,
> >
> > Could anyone tell me how to eregi a word, to see if it only contains
either
> > numbers, letters, the "_" and the "-", so that any other symbol with
call it
> > invalid. For example, theres the word "expressio_n" that will be valid,
but
> > the word "express%^$-n" will be invalid.
> >
> > Thankyou,
> >
> > Tim
> >
> >
> >
> >
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eregi

2001-10-01 Thread Rasmus Lerdorf

See php.net/strcspn

On Mon, 1 Oct 2001, Tim Ballantine wrote:

> Hello,
>
> Could anyone tell me how to eregi a word, to see if it only contains either
> numbers, letters, the "_" and the "-", so that any other symbol with call it
> invalid. For example, theres the word "expressio_n" that will be valid, but
> the word "express%^$-n" will be invalid.
>
> Thankyou,
>
> Tim
>
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Eregi for Image

2001-08-26 Thread Daniel Rezny

Hello Jeff,

Sunday, August 26, 2001, 9:17:45 PM, you wrote:

JO> I want to check if an uploaded file is an image. This isn't working. 
JO> Could anyone  help me out?

JO> if (!eregi("\\.gif$", $img1_name) || 
JO> !eregi("\\.jpg$", $img1_name) || 
JO> !eregi("\\.jpeg$", $img1_name)) {
JO> error message
JO> }

You can find out type of uploaded file like this:

if ($img1_name_type=='gif') {
image is gif do this
   }
else {
 image is not gif do that
}

I hope it helps


-- 
Best regards,
 Danielmailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] EREGI -- Help

2001-05-16 Thread Johnson, Kirk

Give this a try:

if(!ereg("^([0-9]{5}([-]{1}[0-9]{4})?)$",$data)) {

Kirk

> -Original Message-
> From: Jason Caldwell [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 15, 2001 8:16 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] EREGI -- Help
> 
> 
> I'm just trying to create a eregi expression that will evaluate a zip
> code... and I cannot get it to work... can anyone assist me 
> with this?  --
> also, is there a site that shows regular expression examples 
> for checking
> fields like, zip codes, phone numbers, etc...
> 
> if(!(eregi("(^[0-9]{5})(\\-([0-9]{4}$))?", $data)))
>  $err[] = $desc . " - Invalid Zip Code " . $req;
> 
> Thanks
> Jason

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] eregi not working???

2001-03-20 Thread David Robley

On Wed, 21 Mar 2001 08:46, Clayton Dukes wrote:

> > I have a script that looks for  tags, but it doesn't seem to be
> picking up the titles, can anyone tell me why?
>
>
>  Almost all of the web pages look like:
>
>if(!isset($mainfile)) { include("mainfile.php"); }
>  if(!isset($headers_sent)) { include("header.php"); }
>  ?>
>  
>  
>  
> Some Title
> 
>
>  
>
>
> Here's my function:
>
>  function getTitle(&$doc)
>  {
>  if (eregi("(.*)", $doc, $titlematch))
>  $title = trim(eregi_replace("[[:space:]]+", " " ,
> $titlematch[1])); else
>  $title = "";
>  if ($title == "")
>  $title = "Untitled Document";
>  return $title;
>  }
>
> it runs okay...
>  But, when I use the function, everything is coming back as "Untitled
> Document".
>
>  Any suggestions?
>
>
>  Clayton Dukes


Can't tell you what your problem is, but FWIW here is what I use to do 
the job - if you can extract some useful bits from that

", $contents[$i])):
  $exists=true;
endif;

if($exists):
  $title .= $contents[$i];
endif;

if(eregi("", $contents[$i])):
  break;
endif;

  }   /* End FOR */

  /* Get rid of end of line in case title tag is spread over multiple 
lines */
  $title = eregi_replace(10, "", $title);
  $title = eregi_replace(13, "", $title);
  if( (empty($title)) || (strtoupper($title) == "")):
$title = 'Research Centre for Injury Studies';
  endif;
  /* Clear the slashes, in case there are wonky chars in the title 
(Thanks, James!) */
  return stripslashes($title);
}   /* End function get_title */
?>

-- 
David Robley| WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet| http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]