0

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

How this can be achieved using mule filters?

Alex Kulinkovich
  • 4,408
  • 15
  • 46
  • 50
Mangoski
  • 2,058
  • 5
  • 25
  • 43
  • What do you need to do? Filter messages containing '/asdf'? Split the '/asdf' message into '/' and 'asdf'? Remove '/' from '/asdf'? – Ale Sequeira May 05 '14 at 20:15
  • I need to filter slash(/) from the string . If I give the input as /asdf means my output should contain only asdf – Mangoski May 07 '14 at 05:03

2 Answers2

1

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

Anton Kupias
  • 3,945
  • 3
  • 16
  • 20
0

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>
Ale Sequeira
  • 2,039
  • 1
  • 11
  • 19