How to check whether a string is encoded or not in WSO2 ESB?

There might be a requirement to know whether a string is encoded or not in WSO2 ESB’s mediation flow. You can do it via a filter mediator as shown below.

<property name="string" value="abcd"/>
<property name="encodedString" expression="base64Encode('abcd')"/>
<log level="custom">
<property name="encodedString" expression="get-property('encodedString')"/>
</log>
<filter source="get-property('encodedString')"
regex="^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$">
<then>
<log level="custom">
<property name="encoded?" value="yes"/>
</log>
</then>
<else>
<log level="custom">
<property name="encoded?" value="no"/>
</log>
</else>
</filter>
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.