如何使用mule过滤器过滤字符串中的通配符

时间:2014-05-05 10:53:57

标签: mule mule-studio

我有价值/ asdf。我想分开' /'来自字符串。

如何使用mule过滤器实现这一目标?

2 个答案:

答案 0 :(得分:1)

不确定我是否正确理解了您的问题,但是要定义一个匹配&#34; asdf&#34;的通配符过滤器。和&#34; / asdf&#34;在Mule中你只需要<wildcard-filter pattern="*asdf"/>

http://www.mulesoft.org/documentation-3.2/display/32X/Using+Filters#UsingFilters-WildcardFilter

答案 1 :(得分:0)

这应该有效:

    <flow name="test">
        <http:inbound-endpoint exchange-pattern="request-response" host="0.0.0.0" port="8081" path="in"/>
        <scripting:transformer>
            <scripting:script engine="Groovy"><![CDATA[
                def p = java.util.regex.Pattern.compile("^/(.*)")
                def m = p.matcher(message.getPayload())
                if (!m.find()) throw new IllegalArgumentException('Message does not start with /')
                return m.group(1)
            ]]></scripting:script>
        </scripting:transformer>
</flow>