How to split the String based on condition?

hi ,
I have a String str="/opt/ibm/lotus/ibw/latest" or ="/opt/lotus/ibw/latest" this value is dynamic..I want to split this string into 2 strings

  1. /opt/ibm/lotus(/opt/lotus) this string must ends with "lotus"
    2./ibw/latest

can any body help me on this?

Regards,
sankar

For the first part use this:

"${str%${str#*lotus}}"

for the second this:

"${str#*lotus}"

Or with sed:

echo "/opt/ibm/lotus/ibw/latest" | sed 's!\(.*lotus\).*!\1!'

gives: /opt/ibm/lotus

echo "/opt/ibm/lotus/ibw/latest" | sed 's!.*lotus\(.*\)!\1!'

gives: /ibw/latest

Regards