Help with preg_match and windows domain logins...
| From: | Daevid Vincent | Date: | Mon, 12 Dec 2005 23:40:16 +0000 |
| Subject: | Help with preg_match and windows domain logins... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-227354@lists.php.net to get a copy of this message | ||
I'm trying to do what should be a very simple regex, but can't seem to get
PHP to work, yet regex-coach and even an XML .XSD work fine:
Valid forms of a windows logon are:
"foo\bar"
"\\foo\bar"
function isValidWinLogon($logon)
{
//$logon = '\\\\foo\\bar';
$logon = '\\foo\bar';
print "<P><PRE>logon = '$logon'<BR></PRE>\n";
preg_match('/(\\\\)?.+\\.+/', $logon, $matches);
//preg_match('/(\\\\)?.+(\\).+/', $logon, $matches);
print_r($matches);
return (count($matches) > 0);
}
I'm obviously passing in the strings, but for testing, I tried to hard-code
it.
First, when I use single ticks, I thought that meant to be taken literally.
Seems I still have to escape (\) the backslashes.
In either case, the $matches array is EMPTY.
Further more, WTF do I get this error:
"Compilation failed: missing ) at offset 12" (pointing to the commented out
preg_match.
WTF should adding a set of parenthesis cause a compilation error?!
# php -v
PHP 5.0.3 (built: Dec 1 2005 02:20:49)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies
with Zend Extension Manager v1.0.9, Copyright (c) 2003-2005, by Zend
Technologies
with Zend Optimizer v2.6.0, Copyright (c) 1998-2005, by Zend
Technologies