title: MULE ESB : Expression Filter with regex() function
body: <p>I'm having as payload some Json data like :</p>
  
  <pre><code>{
      "name" : "Italy"
  }
  </code></pre>
  
  <p>I want to filter with a regex the content of my field "name".</p>
  
  <p>By now I user this filter. There's no real error but it doesn't match. </p>
  
  <pre><code>&lt;expression-filter expression="regex('^[a-zA-Z]{3,15}$' , 'json:name')" doc:name="Expression"/&gt;
  </code></pre>
  
  <p>As a proof of using this regex() function if I put <code>'(.*)'</code> as regex pattern, it works. </p>
  
  <pre><code>&lt;expression-filter expression="regex('(.*)' , 'json:name')" doc:name="Expression"/&gt;
  </code></pre>
  
  <p>The documentation is <a href="http://www.mulesoft.org/documentation/display/current/Mule+Expression+Language+Tips" rel="nofollow">here</a>.</p>
  
  <p>Someone understands my mistake?</p>
  
  <p>[EDIT]</p>
  
  <p>Then Matthew's solution works like that :</p>
  
  <pre><code>    &lt;set-variable variableName="PayloadBackup" value="#[payload]" doc:name="Variable"/&gt;&lt;json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/&gt;
      &lt;expression-transformer expression="#[payload['name'].matches('^[a-zA-Z]{3,15}$')]" doc:name="Expression"/&gt;
      &lt;expression-filter expression="#[payload]" doc:name="Expression"/&gt;
      &lt;set-payload value="#[PayloadBackup]" doc:name="Set Payload"/&gt;
  </code></pre>
  
  <p>It's ugly though. </p>
  
  <p>If the string doesn't match the regex, the engine answer :</p>
  
  <pre><code>null (java.lang.NullPointerException). Message payload is of type: Boolean
  </code></pre>
  
  <p>I'm not able to catch this Excetion yet. </p>
  
  <p>Thanks</p>