NYCPHP Meetup

NYPHP.org

[nycphp-talk] RegExp Assistance

Timothy Boyden tboyden at supercoups.com
Thu Mar 1 16:59:01 EST 2007


Thanks Cliff, I'll have to get Regex Buddy, that's a cool tool to have.

-Tim

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On Behalf Of Cliff Hirsch
Sent: Thursday, March 01, 2007 3:17 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] RegExp Assistance

It's so simple! Seriously, I've said it before -- Regex Buddy is
awesome.

Here's the output:

email explanation

/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z
]{2})?)$/

Match the character "/" literally </>
Assert position at the start of the string <^> Match the regular
expression below and capture its match into backreference number 1
<(\w+(?:\.\w+)*)>
   Match a single character that is a "word character" (letters, digits,
etc.) <\w+>
      Between one and unlimited times, as many times as possible, giving
back as needed (greedy) <+>
   Match the regular expression below <(?:\.\w+)*>
      Between zero and unlimited times, as many times as possible,
giving back as needed (greedy) <*>
      Match the character "." literally <\.>
      Match a single character that is a "word character" (letters,
digits,
etc.) <\w+>
         Between one and unlimited times, as many times as possible,
giving back as needed (greedy) <+> Match the character "@" literally <@>
Match the regular expression below and capture its match into
backreference number 2 <((?:\w+\.)*\w[\w-]{0,66})>
   Match the regular expression below <(?:\w+\.)*>
      Between zero and unlimited times, as many times as possible,
giving back as needed (greedy) <*>
      Match a single character that is a "word character" (letters,
digits,
etc.) <\w+>
         Between one and unlimited times, as many times as possible,
giving back as needed (greedy) <+>
      Match the character "." literally <\.>
   Match a single character that is a "word character" (letters, digits,
etc.) <\w>
   Match a single character present in the list below <[\w-]{0,66}>
      Between zero and 66 times, as many times as possible, giving back
as needed (greedy) <{0,66}>
      Match a single character that is a "word character" (letters,
digits,
etc.) <\w>
      The character "-" <->
Match the character "." literally <\.>
Match the regular expression below and capture its match into
backreference number 3 <([a-z]{2,6}(?:\.[a-z ]{2})?)>
   Match a single character in the range between "a" and "z"
<[a-z]{2,6}>
      Between 2 and 6 times, as many times as possible, giving back as
needed (greedy) <{2,6}>
   Match the regular expression below <(?:\.[a-z ]{2})?>
      Between zero and one times, as many times as possible, giving back
as needed (greedy) <?>
      Match the character "." literally <\.>
      Match a single character present in the list below <[a-z ]{2}>
         Exactly 2 times <{2}>
         A character in the range between "a" and "z" <a-z>
         One of the characters "
" <
>
Assert position at the end of the string (or before the line break at
the end of the string, if any) <$> Match the character "/" literally </>


Created with RegexBuddy



On 3/1/07 11:11 AM, "Timothy Boyden" <tboyden at supercoups.com> wrote:

> Any RegExp gurus care to do an educational breakdown of the RegEx 
> filter in that function?
> 
> I just can't get my head around regular expressions, too much like 
> algebra and Perl  ;-p
> 
> TIA,
> 
> Tim
> 
> 
> -----Original Message-----
> From: talk-bounces at lists.nyphp.org 
> [mailto:talk-bounces at lists.nyphp.org]
> On Behalf Of Alvaro P.
> Sent: Thursday, March 01, 2007 10:57 AM
> To: NYPHP Talk
> Subject: Re: [nycphp-talk] RegExp Assistance
> 
> I use this function:
> 
> function validateEmail(email)
> {
>         var
> filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a
> -z
> ]{2})?)$/i;
>         if(filter.test(email)==true) {
>                 return true;
>         } else{
>                 return false;
>         }
> 
> }
> 
> 


_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php



More information about the talk mailing list