Help with preg_match and windows domain logins...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux