View Single Post
  #6 (permalink)  
Old 06-29-2007, 02:14 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Admin
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 442
iTrader: (0)
TeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to behold
Lee, I don't understand your problem with the first regular expression. You want it to start with a letter. admin-# starts with "a" which is a letter.

Your second expression only allows a 1 character string (start and end are set and you've give one character in-between).

If you're trying to sanitize a username, let me recommend a different approach. I don't know the ereg syntax, so I'll give it to you with perl expressions.

PHP Code:
<?php
$username 
"admin-#";

//Strip out all non-letters and numbers from the entire string.
$username_sanitized preg_replace('/[^a-z0-9]/i','',$username);

if (
$username_sanitized == $username) {
  
//No bad characters were removed, so this is a good username
  
echo "<p>Good username.</p>";
} else {
  
//At least one character was removed
  
echo "<p>Bad username.  Try ".$username_sanitized." instead.</p>";
}
?>

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote