Hey there,
I'm trying to make use of the RegExp library to parse the MAC address from the
output of the Windows "ipconfig" program. I have an RE that I have tested using
the Applet on your site and it is working fine. However, when I run the exact
same RE in my code, it is failing.
Here's the text I'm searching (Apologize in advance if this messes with your
MUA, but figured exactness was preferred...):
Host Name . . . . . . . . . . . . : xxx Primary Dns Suffix . . . . . . . :
xxx Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . .
. . . : No WINS Proxy Enabled. . . . . . . . : No DNS Suffix Search List. .
. . . . : xxx xxxEthernet adapter Local
Area Connection: Connection-specific DNS Suffix . : Description . . . . .
. . . . . . : Marvell Yukon 88E8001/8003/8010 PCI Gigabit Ethernet Controller
Physical Address. . . . . . . . . : 00-11-2F-C9-0E-34 DHCP Enabled. . . . . .
. . . . . : No IP Address. . . . . . . . . . . . : 10.1.1.1 Subnet Mask . .
. . . . . . . . . : 255.255.255.255 Default Gateway . . . . . . . . . :
10.1.1.1 DNS Servers . . . . . . . . . . . : 10.1.1.1
10.2.1.5 Primary WINS Server . . . . . . . : 10.1.1.1
Secondary WINS Server . . . . . . : 10.1.1.1
Here's the RE I'm using:
([:xdigit:]{2})(\-[:xdigit:]{2}){5}
Here's the output I see from the applet:
Matches.
$0 = 00-11-2F-C9-0E-34
$1 = 00
$2 = -11
$3 = -2F
$4 = -C9
$5 = -0E
$6 = -34
Here's my code snippet:
private static String getEthernetAddressFromIPConfig()
{
String ipconfig = getIPConfig();
ServiceDebugger.println("Text to search: " + ipconfig);
ServiceDebugger.println("Regular Expression to extract MAC: " + IPRE);
RE re = new RE();
try {
re.setProgram(new RECompiler().compile(IPRE));
}
catch(RESyntaxException ex) {
throw new RuntimeException("Failed to compile RE: " +
ex.getMessage(), ex);
}
if(re.match(ipconfig)) {
ServiceDebugger.println("MAC address found: " + re.getParen(0));
return re.getParen(0);
}
else {
ServiceDebugger.println("MAC not found.");
}
return null;
}
I'm wondering if I'm not setting up the RE variable correctly. Also, I'm using
the 1.3 version of the library. Let me know if any more info would be useful.
Thanks in advance,
Sam Wilson
Senior Software Engineer
610-941-4600 x228
610-941-4660 (fax)
[EMAIL PROTECTED]
http://www.ecount.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]