Mule MEL to do substring on a flow variable

user1493140 picture user1493140 · May 11, 2014 · Viewed 18.6k times · Source

I have a variable my_variable with value as a dynamic URL like --

http://stackoverflow.com/questions/ask

I want to do a substring on this dynamic URL to find the string after last "/" i.e. in case above mentioned URL, I want to get the substring "ask"

How can I use MEL to do that?

Answer

user1760178 picture user1760178 · May 13, 2014

You can use the string functions which are availalbe from the java.lang package.

#[flowVars['my_variable'].substring(flowVars['my_variable'].lastIndexOf('/'))]

Hope this helps.