NetXMS Support Forum

English Support => General Support => Topic started by: VMGuy on January 26, 2015, 09:57:45 PM

Title: Regex problem
Post by: VMGuy on January 26, 2015, 09:57:45 PM
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
Title: Re: Regex problem
Post by: Alex Kirhenshtein on January 27, 2015, 09:30:19 AM
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(.+)$"