Hi Amila, I think if "matcher.find()" worked "correctly" for the strings worked for "matcher.matches()", there would not be any issue. Indeed, It shouldn't be . BTW, I do not know whether any kind of notable performance difference is there.
Thanks, Indika On Wed, Nov 9, 2011 at 9:59 AM, Amila Maha Arachchi <[email protected]> wrote: > 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]*([email protected])[\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 <[email protected]>". But, normally if i > put [email protected] 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. >
