Forum Discussion

Raymond_Feng_97's avatar
Raymond_Feng_97
Historic F5 Account
Jul 31, 2012

urgent: need help for regular expression ?

Hi, all

Sorry , I am on site , can anybody help to create one line simple iRule to get the FQDN from the below sip string ?

 

ECSCF-Simulator7.P-LRF.com;lr>

 

Route: ECSCF-Simulator7.P-LRF.com;lr>

 

 

 

Contact: sip.test-site2.ERICSSON2.com:5060>

 

 

 

 

the fqdn is after "sip:" and "@" (if exist") and before ":" or ";"

 

 

 

I want to set the fqdn to one value and do dns query for this domain name , and then change change the destination ip to be that address.

 

 

 

Thanks.

 

 

 

Raymond

 

  • Hi Raymond,

     

     

    Can you post the input sample in [ code ] [/ code ] blocks without the spaces?

     

     

    Here's a related post you can reference as well:

     

     

    https://devcentral.f5.com/Forums/tabid/53/aft/60465/Default.aspx60474

     

     

    Thanks, Aaron
  • Raymond_Feng_97's avatar
    Raymond_Feng_97
    Historic F5 Account
    
    Route:
    Contact:
     

    I want get the FQDN out of the SIP header string , like "sip.test-site2.ERICSSON2.com" and "ECSCF-Simulator7.P-LRF.com" . Thanks.
  • Can you post a few more examples of the two different header values?

     

     

    Are you able to parse the route and contact headers using separate logic?

     

     

    Here's a first stab at a combined regex that matches the domain of both examples you've shown:

     

     

    (?:(?<=@).*?(?=;|:)|(?<=

     

    Aaron
  • Raymond_Feng_97's avatar
    Raymond_Feng_97
    Historic F5 Account
    Sure I can using separate logic for Route and contact , actually my question is focus the FQDN may or may not have "@" .

     
    Contact:
    Contact:
    Contact:
    Contact:
    

    these is four examples , can I get the sip.test-site2.ericsson2.com with same regex ?

  • The last regex didn't render correctly. And as TCL advanced regexes don't support lookbehinds, the regex won't work. You can do two scan commands for this though:
    when RULE_INIT {
    
     Loop through some test strings:
    foreach str [list 
    {}
    {}
    {}
    {}
    {}
    {}] {
    
     Scan assuming a format of