Having trouble with Regular Expressions here too

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

 



Here is what I'm doing:

I'm issuing a DOS command on a Windows platform using the backtick mark
(`command`) and getting output from it. That works fine. Now my problem
is parsing the string that gets returned. 
I've tried using the preg_match and preg_match_all commands to filter
the information I want, but can't seem to get them to work. I'm not sure
if they are the ones I need to use. I'm attempting to use the following
pattern filter with the preg_match commands: 

if (preg_match("/starting./", $output) == 0) {
	print "Error logging on to server - unable to get user list.\n";
} else {
	array_shift($output);
	array_pop($output);

	foreach ($output as $line) {
		$search_pattern =
"/\s*([^\s]*)\s*AKA\s*\"([^\"]*)\"\s*IN\s*([^\^]*)\^([^\(]*).*/)";

		if ( preg_match( $search_pattern, $line, $outarray,
PREG_OFFSET_CAPTURE) > 0) {
			print "match found";	
		} else {
			print "Error found\n";
			exit;
		}
	}
}

The above code was taken from a PERL script and modified for PHP.

Data output as follows.. Some information has been blanked out for
privacy reasons.

------- Cut here - Data Begin -----------------------------------

Operator Console (version 0.9.8) for 'XXX.XXX.XXX.XXX' starting.
  [UIN]                 AKA "[USERNAME]" IN [URL^ROOMNAME]
(XXXX:XXXX:XXXX)
Operator Console for 'XXX.XXX.XXX.XXX' signing off

------- Cut here - Data End -----------------------------------

The (XXXX:XXXX:XXXX) in the data above can contain alphanumeric
characters.
The large bit of space between the [UIN] and the AKA is actually in the
real data.

Any suggestions? 

Thanks much in advance,
Jim 

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux