试图构建regex需要对此进行输入

  • 本文关键字:构建 regex regex
  • 更新时间 :
  • 英文 :


我有一个字符串

<sip:a39pbx@47.168.156.141:5060;maddr=47.168.156.141>;expires=703,<sip:739pbxast25@47.168.156.141:5060;maddr=47.168.156.141>;expires=826;

想要提取过期及其值,我已经尝试使用

(.*)(expires=d*);(.*)

但它只给了我最后一个,它是expires=826,我想选择另一个,或者也以,结尾。

欢迎任何意见。

您应该尝试如下:

(expires=(d+)),

最后一个逗号将帮助您匹配以,结尾的值。它将用键&值和另一个仅具有值。

实时演示

(expires=d+)

http://regex101.com/r/sQ5bJ7

(expires=d+)
Match the regular expression below and capture its match into backreference number 1 «(expires=d+)»
   Match the characters “expires=” literally «expires=»
   Match a single digit 0..9 «d+»
      Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»

最新更新