【发布时间】:2011-06-27 11:34:17
【问题描述】:
我的条件中有以下字符串:10.13.0.90:7000
我想把它提取成两个条件,例如10.13.0.90和7000。
我试过了
<propertyregex property="client.ip" input="${client.address}" regexp="[0-9.]*:[0-9]*" select="\1" /> 但这不起作用。条件肯定是正确的。有什么建议吗?
非常感谢!
【问题讨论】:
我的条件中有以下字符串:10.13.0.90:7000
我想把它提取成两个条件,例如10.13.0.90和7000。
我试过了
<propertyregex property="client.ip" input="${client.address}" regexp="[0-9.]*:[0-9]*" select="\1" /> 但这不起作用。条件肯定是正确的。有什么建议吗?
非常感谢!
【问题讨论】:
\1 表示第一个分组。但你根本没有分组()。
试试这个:
<propertyregex property="client.ip" input="${client.address}"
regexp="([0-9\.]*):[0-9]*" select="\1" />
【讨论】:
您需要使用括号来捕获您使用“\1”引用的组,例如
regexp="([0-9.]*):[0-9]*"
顺便说一句,您可以使用\d 而不是[0-9] 来表达数字,例如
regexp="(\d.*):\d*"
【讨论】: