如何使用模式和组来验证属性。
<property name="string" [action=set|remove] [type="string"]
(value="literal" | expression="xpath")
[scope=default|transport|axis2|axis2-client] [pattern="regex"
[group="integer"]]>
</property>
答案 0 :(得分:0)
属性中介器中的模式可用于将值或表达式的结果与给定模式进行匹配。如果模式匹配,则属性介体返回该值。否则,它返回一个空字符串。
例如,在下面的示例中,只有Test1属性值与模式匹配。因此,只有Test1返回该值。 Test2返回一个空字符串。
<property name="Test1" value="5" scope="default" type="STRING" pattern="[0-9]" group="0"/>
<property name="Test2" value="20" scope="default" type="STRING" pattern="[0-9]" group="0"/>
<log level="custom">
<property name="Test1 Value : " expression="get-property('Test1')"/>
<property name="Test2 Value : " expression="get-property('Test2')"/>
</log>
并且,属性中介器中的“ group”属性用于根据此匹配器模式中的捕获组数进行评估,类似于Java中的java.util.regex.Matcher.groupCount()。但是,目前显然在WSO2 EI 6.5.0中没有组支持。