天天看點

【SIPp】正規表達式

本文旨在介紹SIPp中正則使用示例。深入請轉https://blog.csdn.net/m0_37962554/article/details/77140894

以下記憶體摘自http://sipp.sourceforge.net/doc/regexp.xml.html

56:  <recv response="200" start_rtd="true">
  57:    <!-- Definition of regexp in the action tag. The regexp must follow -->
  58:    <!-- the Posix Extended standard (POSIX 1003.2), see:               -->
  59:    <!--                                                                -->
  60:    <!--   http://www.opengroup.org/onlinepubs/007908799/xbd/re.html    -->
  61:    <!--                                                                -->
  62:    <!-- regexp    : Contain the regexp to use for matching the         -->
  63:    <!--             received message                                   -->
  64:    <!--             MANDATORY                                          -->
  65:    <!-- search_in : msg (try to match against the entire message)      -->
  66:    <!--           : hdr (try to match against a specific SIP header    -->
  67:    <!--             (passed in the header tag)                         -->
  68:    <!--             OPTIONAL - default value : msg                     -->
  69:    <!-- header    : Header to try to match against.                    -->
  70:    <!--             Only used when the search_in tag is set to hdr     -->
  71:    <!--             MANDATORY IF search_in is equal to hdr             -->
  72:    <!-- check_it  : if set to true, the call is marked as failed if    -->
  73:    <!--             the regexp doesn't match.                          -->
  74:    <!--             OPTIONAL - default value : false                   -->
  75:    <!-- assign_to : contain the variable id (integer) or a list of     -->
  76:    <!--             variable id which will be used to store the        -->
  77:    <!--             result of the matching process between the regexp  -->
  78:    <!--             and the message. This variable can be re-used at   -->
  79:    <!--             a later time in the scenario using '[$n]' syntax   -->
  80:    <!--             where n is the variable id.                        -->
  81:    <!--             MANDATORY                                          -->
  82:    <action>
  83:      <ereg regexp="[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[:][0-9]{1,5}" 
  84:            search_in="msg" 
  85:            check_it="true" 
  86:            assign_to="1"/>
  87:      <ereg regexp=".*" 
  88:            search_in="hdr" 
  89:            header="Contact:" 
  90:            check_it="true" 
  91:            assign_to="6"/>
  92:      <ereg regexp="o=([[:alnum:]]*) ([[:alnum:]]*) ([[:alnum:]]*)"
  93:            search_in="msg" 
  94:            check_it="true" 
  95:            assign_to="3,4,5,8"/>
  96:    </action>
  97:  </recv>      

此内容僅供參考,如有疏漏,望指教。