Regex problem

Started by VMGuy, January 26, 2015, 09:57:45 PM

Previous topic - Next topic

VMGuy

Hi,

to extract the interface name from Net.InterfaceList I use this regular expression: "^(.+?)\s+(.+?)\s+(.+?)\s+(.+?)\s+(.+)$"
The reason is that Windows could contain spaces in the interface name: 13 10.141.120.11/23 6 000C29F2B70D LAN-Verbindung 2

It seems like NetXMS doesn't honor the non-greedy operator, because the result is:
$1 = 13 10.141.120.11/23
$2 = 6
$3 = 000C29F2B70D
$4 = LAN-Verbindung
$5 = 2

Actually $5 should be: LAN-Verbindung 2

Thanks, VMGuy

Alex Kirhenshtein

Looks like a bug in libtre, we'll look into it.

In meantime you can use this regexp: "^([0-9]+)\s([0-9./]+)\s([0-9]+)\s([0-9A-F]+)\s(.+)$", or a bit more generic: "^([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s(.+)$"