On 15 Apr 2015, at 16:15, Arran Cudbard-Bell <a.cudbardb@freeradius.org> wrote:
On 15 Apr 2015, at 15:08, Alan DeKok <aland@deployingradius.com> wrote:
On Apr 15, 2015, at 9:29 AM, Kostas Zorbadelos <kzorba@otenet.gr> wrote:
I am trying to perform a match against the full Cisco-AVPair string (Cisco-AVPair[*]) to get a specific part. The exact check I am performing is
It would be better to loop over the Cisco-AVPairs with a "foreach", and the match the one you want.
No, the way he's doing it should work.
(0) update request { (0) Cisco-AVPair := 'foo=bar' (0) Cisco-AVPair += 'bar=baz' (0) Cisco-AVPair += 'baz=foo' (0) } # update request = noop (0) if (&Cisco-AVPair[*] =~ /bar=(.*)/) { (0) if (&Cisco-AVPair[*] =~ /bar=(.*)/) -> TRUE (0) if (&Cisco-AVPair[*] =~ /bar=(.*)/) { (0) if ("%{1}" != 'baz') { (0) EXPAND %{1} (0) --> baz (0) if ("%{1}" != 'baz') -> FALSE (0) } # if (&Cisco-AVPair[*] =~ /bar=(.*)/) = noop (0) ... skipping else for request 0: Preceding "if" was taken It works because the matching is short circuited when it finds a value that matches the regex. So the capture groups are from the last value that matched. Anyway, added a test case to make sure it doesn't break in future. -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2