FreeRADIUS 2.X.X small functionality extensions

Kostas Zorbadelos kzorba at
Fri Jun 6 14:09:15 CEST 2014

Arran Cudbard-Bell <a.cudbardb at> writes:

>     Yes indeed, he refused to add it.
>     I our case I managed to overcome the problem by defining a
>     slightly
>     different regex. It is true that the info I 'd like to extract is
>     only 5
>     variables (fitting in the 8) but more groups can be needed in more
>     compicated expressions. In our case the original regex was
>     /.*_((HUA)|(ALU))_([[:digit:]]+)(.*)? ((atm)|(eth))
>     ([[:digit:]]+)\/([[:digit:]]+)\/([[:digit:]]+)\/([[:digit:]]+)
>     (:)?.*/
>     and I reduced the groups with
>     /.*__([[:digit:]]+)(.*)? [atmeth]{3} 0?([[:digit:]]+)\/0?
>     ([[:digit:]]+)\/0?([[:digit:]]+)\/0?([[:digit:]]+)(:)?.*/)
>     Not exactly the same but fits our purposes fine.
>     [HUAALU]{3}
> That'll work, but it's pretty bad.

Yes, I know.

>     ((HUA)|(ALU))
> Inputting (ALU|HUA) on debuggex, you get:
> *
> Meaning HUA and ALU count as atoms for the alternation. In fact
> (HUA|ALU) is exactly the same thing as ((HUA)|(ALU)) but uses two
> fewer capture groups.

This is very nice.

> I can't remember if it's the same in extended regular expressions but
> for PCRE at least 
> (?:<expression>) makes expression an atom, but doesn't add the match
> to the capture groups.
> 'foo bar baz' =~ /([[:alnum:]]+) (?:[[:alnum:]]+) ([[:alnum:]]+)/
> Would result in 
> %{0} -> 'foo bar baz'
> %{1} -> 'foo'
> %{2} -> 'baz'
> So you don't waste the capture groups if you're not actually going to
> use the data.

Very useful, but unfortunately only available in pcre it seems.

> Try it with extended regular expressions and see if it works. If it
> doesn't the only way to fix it would be upgrade to v3.0.x and build
> with PCRE unfortunately.

>     I think generally this is the way to go, have it configurable
>     since
>     people can use it. Matching multiple times to reduce the number of
>     groups is at least "not elegant". Maybe you can have it in the
>     v3.x.x
>     branch? 
> Yes, i'll have a look.

Thanks, although in my case the problem is overcome. Latest version of
regex for my case:

/.*_(HUA|ALU)_([[:digit:]]+)(.*)? (atm|eth) 0?([[:digit:]]+)\/0?([[:digit:]]+)\/0?([[:digit:]]+)\/0?([[:digit:]]+)(:)?.*/ 

which gives me the result in exactly 8 groups. 

> Yes, I know what ISPs can be like :)

Then you are in the group of people who understand ;-)

Thank you and keep up the good work.



More information about the Freeradius-Users mailing list