title: WSO2 ESB 4.8.1 Switch Mediator Case matching not working
body: <p>I am using WSO2 ESB 4.8.1. I need to check if a particular field exists in the Incoming Payload XML. If Iit does, a Switch Case should run, otherwise it should run a default scenario. The field on which I am checking will always have a dynamic value and it would look like following:</p>
  
  <pre><code>20000569899
  </code></pre>
  
  <p>I wrote following logic in ESB:</p>
  
  <pre><code> &lt;property name="CheckIdExist" expression="//*[local-name()='Id']" scope="default" type="STRING" description="CheckIdExist"/&gt;
      &lt;switch source="get-property('CheckIdExist')"&gt;
          &lt;case regex="[a-zA-Z0-9]"&gt;
              &lt;sequence key="SequenceA"/&gt;
              &lt;sequence key="SequenceB"/&gt;
              &lt;sequence key="SequenceC"/&gt;
          &lt;/case&gt;
          &lt;default&gt;
             &lt;log&gt;&lt;/log&gt;
          &lt;/default&gt;
      &lt;/switch&gt;
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>The problem is that Switch is able to pick a value from the property but it does not match the Case regular expression. Following are some ESB Logs Entries:</p>
  
  <p><strong>Logs Entries:</strong></p>
  
  <pre><code>XPath : get-property('CheckIdExist') evaluates to : 20001089900
  
  None of the switch cases matched - executing default
  </code></pre>
  
  <p>I checked online, this regular expression works. So what i am unable to understand is that why WSO2 ESB is not recognizing it as a valid expression. Or is there any other way to check that if a field exists in an input request then a particular switch case should work, Otherwise not.</p>