you can do this in perl

my $example = 11-c0-4f-40-47-b4;

$example =~ /(\d+)\-(\w\d)\-(\d\w)\-(\d+)\-(\d+)\-(\w\d)/;

my $one = ${1};    #11
my $two = ${2};    #c0
etc...

when you have more than one digits you must write \d+ and also for words
\w+.
regular expretions are case sensitive for example if you have a word and a
digit you write this \w\d
and when you want to get it you put $ not %.



Kyriaki Gali,
IT Applications Specialist
Kinetix Tele.com Support Center,
Tel & Fax: +30 2310 256140
GSM: +30 6947 723737
http://www.kinetix.gr
e-mail: [EMAIL PROTECTED]
----- Original Message ----- 
From: "Jose Guevarra" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 19, 2004 2:31 AM
Subject: RE: setting User-Name to 'modified' mac address


> Ok Posix expressions are supported here then shouldn't putting parenthases
> around the hex characters give me groups %{1}...%{6}?
>
> I do this
>
> DEFAULT Calling-Station-Id =~
>
"([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-
>
([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])-([a-fA-F0-9][a-fA-F0-9])"
> User-Name := `%{1}%{2}%{3}%{4}%{5}%{6}`
>
> Instead of getting a mac address with no '-' I get a long weird
combination
> of
> hex and '-'.  I mapped out the ${x} groups and they are not what I expect
>
> for example:
> 11-c0-4f-40-47-b4
>
> becomes groups
>
> %{1} = 11
> %{2} = c0-4f
> %{3} = 4f-40-47
> %{4} = 40-47-b4
> %{5} = 47-b4
> %{6} = b4
>
> Is my regex wrong or what?
>
> Thanks,
>
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Alan
DeKok
> Sent: Monday, October 18, 2004 11:40 AM
> To: [EMAIL PROTECTED]
> Subject: Re: setting User-Name to 'modified' mac address
>
> Jose Guevarra <[EMAIL PROTECTED]> wrote:
> > In my hints file i have
> >
> > DEFAULT Calling-Station-Id =~
> "(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)\-(\w\w)"
> > User-Name := `%{0}`
> >
> > This should set the User Name to the hex characters in the mac address
> > or 'something' at least
>
>   Or something...
>
>   And if you're going to use %{0}, you don't need regular expressions.
> Just use "%{Calling-Station-Id}"
>
> > However, in debug mode I can see that User-Name is not modified.
> >
> > In perl i can use the regex below and it seems to work
>
>   Perl supports "\w" in regular expressions.  Posix expressions (which the
> libraries from your system the server uses) do not support "\w".
>
>   Alan DeKok.
>
>
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
>
>
> -
> List info/subscribe/unsubscribe? See
http://www.freeradius.org/list/users.html


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to