jbclelland
asked on
String search
I have some code stored in a variable that is the output of "ipconfig/all" from a dos command prompt.
I can search through it line by line, but I need to search for a pattern of letters equal to a Mac address of a computer network card.
The code I use at trhe moment is:
// look for 'Physical Address'
foreach ( $lines as $line )
{
if ( substr($line, 0, 16) == 'Physical Address' )
{
$macs[] = substr($line, strlen($line)-17);
}
}
This code works, but only on english versions of Microsoft. I need it to check it on all language versions of Microsoft. How can I search for the MAC address string using PHP regular expressions. I need to search every line in the loop above for the format of characters:
??-??-??-??-??-??
Where ? can be any charachter (so it is six sets of two question marks separated by a - ).
Can you help ?!
Thanks
Ashley :-)
I can search through it line by line, but I need to search for a pattern of letters equal to a Mac address of a computer network card.
The code I use at trhe moment is:
// look for 'Physical Address'
foreach ( $lines as $line )
{
if ( substr($line, 0, 16) == 'Physical Address' )
{
$macs[] = substr($line, strlen($line)-17);
}
}
This code works, but only on english versions of Microsoft. I need it to check it on all language versions of Microsoft. How can I search for the MAC address string using PHP regular expressions. I need to search every line in the loop above for the format of characters:
??-??-??-??-??-??
Where ? can be any charachter (so it is six sets of two question marks separated by a - ).
Can you help ?!
Thanks
Ashley :-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$macAddress = $line[1];
}
-r-