Re: [PHP] regular expressions question

2008-03-07 Thread Richard Lynch
The + requires at least one character.

The * is "0 or more" characters.

http://php.net/pcre

On Wed, March 5, 2008 9:13 am, It Maq wrote:
> Hi,
>
> I am using that right now and i have don't know how to include blank
> fields. For example if a user does not fill a field in a form i want
> to accept it. I tried the code you posted, for now it is blocking
> blank fields.
>
> Thank you
>
> - Original Message 
> From: Richard Lynch <[EMAIL PROTECTED]>
> To: Adil Drissi <[EMAIL PROTECTED]>
> Cc: php-general@lists.php.net
> Sent: Tuesday, March 4, 2008 3:09:09 PM
> Subject: Re: [PHP] regular expressions question
>
> On Tue, March 4, 2008 1:19 pm, Adil Drissi wrote:
>> Is there any way to limit the user to a set of characters for
>> example
>> say i want my user to enter any character between a and z (case
>> insensitive). And if the user enters just one letter not belonging
>> to
>> [a-z], this will not be accepted.
>>
>> I tried  eregi('[a-z]', $fname) but this allows the user to enter
>> abdg4512kdkdk for example.
>
> What you tried only requires ONE a-z character somewhere in the input.
>
> Try this:
>
> preg_match('^[a-z]+$', $fname);
>
> This will:
> ^ "anchor" the string at the beginning
> [a-z]+ a to z, with at least one letter
> $ "anchor" the string at the end
>
> Note, however, that some people have other characters in their first
> name, such as apostrophe, space, and dash.
>
> Oh, and the digit 3, for "bo3b" who was a programmer on the first
> Apple Macintosh.  His parents were hippies, and that really is his
> name...
>
> You may want to obtain a LARGE list of "first names" and run them
> through your validator as a test.
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/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
>
>
>
>
>
>
>
>   
> 
> Never miss a thing.  Make Yahoo your home page.
> http://www.yahoo.com/r/hs


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/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] regular expressions question

2008-03-05 Thread Robert Cummings

On Wed, 2008-03-05 at 07:13 -0800, It Maq wrote:
> Hi,
> 
> I am using that right now and i have don't know how to include blank fields. 
> For example if a user does not fill a field in a form i want to accept it. I 
> tried the code you posted, for now it is blocking blank fields.
> 
> Thank you
> 
> - Original Message 
> From: Richard Lynch <[EMAIL PROTECTED]>
> To: Adil Drissi <[EMAIL PROTECTED]>
> Cc: php-general@lists.php.net
> Sent: Tuesday, March 4, 2008 3:09:09 PM
> Subject: Re: [PHP] regular expressions question
> 
> On Tue, March 4, 2008 1:19 pm, Adil Drissi wrote:
> > Is there any way to limit the user to a set of characters for example
> > say i want my user to enter any character between a and z (case
> > insensitive). And if the user enters just one letter not belonging to
> > [a-z], this will not be accepted.
> >
> > I tried  eregi('[a-z]', $fname) but this allows the user to enter
> > abdg4512kdkdk for example.
> 
> What you tried only requires ONE a-z character somewhere in the input.
> 
> Try this:
> 
> preg_match('^[a-z]+$', $fname);

preg_match('^[a-z]*$', $fname);

Someone else posted this also, but you may have missed it.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] regular expressions question

2008-03-05 Thread It Maq
Hi,

I am using that right now and i have don't know how to include blank fields. 
For example if a user does not fill a field in a form i want to accept it. I 
tried the code you posted, for now it is blocking blank fields.

Thank you

- Original Message 
From: Richard Lynch <[EMAIL PROTECTED]>
To: Adil Drissi <[EMAIL PROTECTED]>
Cc: php-general@lists.php.net
Sent: Tuesday, March 4, 2008 3:09:09 PM
Subject: Re: [PHP] regular expressions question

On Tue, March 4, 2008 1:19 pm, Adil Drissi wrote:
> Is there any way to limit the user to a set of characters for example
> say i want my user to enter any character between a and z (case
> insensitive). And if the user enters just one letter not belonging to
> [a-z], this will not be accepted.
>
> I tried  eregi('[a-z]', $fname) but this allows the user to enter
> abdg4512kdkdk for example.

What you tried only requires ONE a-z character somewhere in the input.

Try this:

preg_match('^[a-z]+$', $fname);

This will:
^ "anchor" the string at the beginning
[a-z]+ a to z, with at least one letter
$ "anchor" the string at the end

Note, however, that some people have other characters in their first
name, such as apostrophe, space, and dash.

Oh, and the digit 3, for "bo3b" who was a programmer on the first
Apple Macintosh.  His parents were hippies, and that really is his
name...

You may want to obtain a LARGE list of "first names" and run them
through your validator as a test.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/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







  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

Re: [PHP] regular expressions question

2008-03-04 Thread Adil Drissi
Thank you guys,

The answers you gave me not only solved the problem,
but i included more characters like space and -.

Thank you again

--- Richard Lynch <[EMAIL PROTECTED]> wrote:

> On Tue, March 4, 2008 1:19 pm, Adil Drissi wrote:
> > Is there any way to limit the user to a set of
> characters for example
> > say i want my user to enter any character between
> a and z (case
> > insensitive). And if the user enters just one
> letter not belonging to
> > [a-z], this will not be accepted.
> >
> > I tried  eregi('[a-z]', $fname) but this allows
> the user to enter
> > abdg4512kdkdk for example.
> 
> What you tried only requires ONE a-z character
> somewhere in the input.
> 
> Try this:
> 
> preg_match('^[a-z]+$', $fname);
> 
> This will:
> ^ "anchor" the string at the beginning
> [a-z]+ a to z, with at least one letter
> $ "anchor" the string at the end
> 
> Note, however, that some people have other
> characters in their first
> name, such as apostrophe, space, and dash.
> 
> Oh, and the digit 3, for "bo3b" who was a programmer
> on the first
> Apple Macintosh.  His parents were hippies, and that
> really is his
> name...
> 
> You may want to obtain a LARGE list of "first names"
> and run them
> through your validator as a test.
> 
> -- 
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
> 
> 



  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


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



Re: [PHP] regular expressions question

2008-03-04 Thread Richard Lynch
On Tue, March 4, 2008 1:19 pm, Adil Drissi wrote:
> Is there any way to limit the user to a set of characters for example
> say i want my user to enter any character between a and z (case
> insensitive). And if the user enters just one letter not belonging to
> [a-z], this will not be accepted.
>
> I tried  eregi('[a-z]', $fname) but this allows the user to enter
> abdg4512kdkdk for example.

What you tried only requires ONE a-z character somewhere in the input.

Try this:

preg_match('^[a-z]+$', $fname);

This will:
^ "anchor" the string at the beginning
[a-z]+ a to z, with at least one letter
$ "anchor" the string at the end

Note, however, that some people have other characters in their first
name, such as apostrophe, space, and dash.

Oh, and the digit 3, for "bo3b" who was a programmer on the first
Apple Macintosh.  His parents were hippies, and that really is his
name...

You may want to obtain a LARGE list of "first names" and run them
through your validator as a test.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/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] regular expressions question

2008-03-04 Thread Daniel Brown
On Tue, Mar 4, 2008 at 2:19 PM, Adil Drissi <[EMAIL PROTECTED]> wrote:
> Hi,
>
>  Is there any way to limit the user to a set of characters for example say i 
> want my user to enter any character between a and z (case insensitive). And 
> if the user enters just one letter not belonging to [a-z], this will not be 
> accepted.



-- 


Daniel P. Brown
Senior Unix Geek


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



Re: [PHP] regular expressions question

2008-03-04 Thread David Giragosian
On 3/4/08, Adil Drissi <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Is there any way to limit the user to a set of characters for example say i 
> want my user to enter any character between a and z (case insensitive). And 
> if the user enters just one letter not belonging to [a-z], this will not be 
> accepted.
>
> I tried  eregi('[a-z]', $fname) but this allows the user to enter 
> abdg4512kdkdk for example.
>
> Thank you
>

try here:

http://us2.php.net/ctype_alpha

-- 

-David.

When the power of love
overcomes the love of power,
the world will know peace.

-Jimi Hendrix

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



[PHP] regular expressions question

2008-03-04 Thread Adil Drissi
Hi,

Is there any way to limit the user to a set of characters for example say i 
want my user to enter any character between a and z (case insensitive). And if 
the user enters just one letter not belonging to [a-z], this will not be 
accepted.

I tried  eregi('[a-z]', $fname) but this allows the user to enter abdg4512kdkdk 
for example.

Thank you

   
-
Never miss a thing.   Make Yahoo your homepage.

Re: [PHP] regular expressions question

2002-10-30 Thread jla21
Whoops.. I missed one bit. Rasmus did it right. ;)


On Wed, 30 Oct 2002 [EMAIL PROTECTED] wrote:

> If I understand you correctly, I think you want this?
> 
> $matches = array();
> $test = "(this)example";
> preg_match("/\((.*)\)(.*)/", $test, $matches);
> array_shift($matches);
> 
> On Wed, 30 Oct 2002, Simon Dedeyne wrote:
> 
> > I have a little question. I'm having some difficulty with regular
> > expressions:
> >  
> > here it is:
> > (this)example
> > should be output in an array
> > [0]=> this
> > [1]=> thisexample
> >  
> > I'm supposing this should be done with preg_grep, but I'm not really
> > familiar with some of it's syntax for the regular expression.
> > I could use some ideas,
> >  
> >  
> > cheers,
> > Simon
> >  
> > 
> 
> -- 
> 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] regular expressions question

2002-10-30 Thread jla21
If I understand you correctly, I think you want this?

$matches = array();
$test = "(this)example";
preg_match("/\((.*)\)(.*)/", $test, $matches);
array_shift($matches);

On Wed, 30 Oct 2002, Simon Dedeyne wrote:

> I have a little question. I'm having some difficulty with regular
> expressions:
>  
> here it is:
> (this)example
> should be output in an array
> [0]=> this
> [1]=> thisexample
>  
> I'm supposing this should be done with preg_grep, but I'm not really
> familiar with some of it's syntax for the regular expression.
> I could use some ideas,
>  
>  
> cheers,
> Simon
>  
> 

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




Re: [PHP] regular expressions question

2002-10-30 Thread Rasmus Lerdorf

$str = "(this)example";
preg_match("/\((.*?)\)(.*)/",$str,$regs);
$a[0] = $regs[1];
$a[1] = $regs[1].$regs[2];

On Wed, 30 Oct 2002, Simon Dedeyne wrote:

> I have a little question. I'm having some difficulty with regular
> expressions:
>
> here it is:
> (this)example
> should be output in an array
> [0]=> this
> [1]=> thisexample
>
> I'm supposing this should be done with preg_grep, but I'm not really
> familiar with some of it's syntax for the regular expression.
> I could use some ideas,
>
>
> cheers,
> Simon
>
>


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




[PHP] regular expressions question

2002-10-30 Thread Simon Dedeyne
I have a little question. I'm having some difficulty with regular
expressions:
 
here it is:
(this)example
should be output in an array
[0]=> this
[1]=> thisexample
 
I'm supposing this should be done with preg_grep, but I'm not really
familiar with some of it's syntax for the regular expression.
I could use some ideas,
 
 
cheers,
Simon