Forum Discussion

Jhaunu_Gupta's avatar
Jhaunu_Gupta
Icon for Nimbostratus rankNimbostratus
Sep 18, 2019

Scan header for mdn in irule through regex

Hi,

 

I want to get MDN from header through scan command with regex

 

below is the example of header.

 

% set toheader {tel:+12253941228;tag=MwsjgSMFBd}

tel:+12253941228;tag=MwsjgSMFBd

% scan $toheader {%[^:]:%[0-9]} t2 m2

1

% scan $toheader {%[^:]:%d} t2 m2

2

% puts "$m2"

2147483647

% scan $toheader {%[^:]:%s} t2 m2

2

% puts "$m2"

+12253941228;tag=MwsjgSMFBd

 

through 0-9 it is telling command is not correct with d its giving incorrect value.

 

please help quickly.

 

Thanks in advance

 

1 Reply

  • Hi,

    I did not really understand what you wanted to do or what mdn means

    but hope it will help you.

    find below a simple irule that allow to retrieve value of header:

    when HTTP_REQUEST_DATA {
     
    set toheader "tel:+12253941228;tag=MwsjgSMFBd"
     
    regexp {^tel:([^;]+);tag=(.*)$} $toheader -> tel tag
     
    log local0. "tel: $tel - tag : $tag"
     
    }

    let me know if you need more details or explain me exaclty what is the wanted result!!!

    regards