Hi all,

I wanted to use the switch mediator based on the From address of an email
(using the mail transport). I was using the following configuration.

        <switch source="$trp:From">
            <case regex="^[\w\W]*(ami...@wso2.com)[\w\W]*$">
               <xslt key="MyTransform" />
            </case>
            <default>
               <log level="custom">
                  <property name="sender"
expression="get-property('transport', 'From')" />
               </log>
            </default>

</switch>modules/core/src/main/java/org/apache/synapse/config/xml/SwitchCase.java

I had to use the above mentioned regex because the From address is
something like "Amila Maharachchi <ami...@wso2.com>". But, normally if i
put ami...@wso2.com as the regex it should find a match.

Then I checked the SwitchMediator code and found out that it is using
matcher.matches() method. This checkes whether the whole string is matching
the regex provided (not a part of the string). But, if we use
matcher.find() it will look for a matching subsequence within the string.

Is there any affect to the Switch mediation process in using the
matcher.find() rather than matcher.matches() ?

Thanks,
AmilaM.

Reply via email to