Hi Rob,

----- Original Message ----- 
From: <[EMAIL PROTECTED]>
> Hi Bob,
> It is much faster to do this sort of thing without REGEX -
> 
> if (strlen(strspn(strtolower($addr), 
> "abcdefghijklmnopqrstuvwxyz0123456789/_.-")) != strlen($addr))
>  {
>  // exit; string not valid
>  }

You've shown me something I'd not seen before. Never used strspn(); until now.
Had to look it up to see what it did. I like it.

I removed the 1st strlen() for it to work (if anyone else tries it) but hey, 
you probably typed it from memory.
Something I'm finding harder to do lately :-)

if (strspn(strtolower($addr), 
'abcdefghijklmnopqrstuvwxyz0123456789:/._-') != strlen($addr))
I'll definitely put that one in my toolbox for future reference.

I didn't want to be beaten on the regex though, as it looked simple, and it was.
if (preg_match('/[^a-zA-Z0-9\:\/\.\_\-]/', $addr))
Some of the backslashes are not really needed, but they don't hurt, and I could 
have used "i" for lowercase.
Must have wasted 2 hours on this. I think I'd just spent too long without a 
break.

Many thanks, Bob.




Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-list/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to