Mangoski
Mangoski

Reputation: 2119

How to filter wildcard in string using mule filters

I have value /asdf. I'd like to split the '/' from the string.

How this can be achieved using mule filters?

Upvotes: 0

Views: 1081

Answers (2)

Ale Sequeira
Ale Sequeira

Reputation: 2039

This should work:

    <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>

Upvotes: 0

Anton Kupias
Anton Kupias

Reputation: 4015

Not sure if I correctly understood your question, but to define a wildcard filter that matches both "asdf" and "/asdf" in Mule you need just <wildcard-filter pattern="*asdf"/>

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

Upvotes: 1

Related Questions