inputs: ********* #$str='make -r -f ..\../tools/cell/makefile cell.lib'; $str='make -r -f ..\../system-build/ali/text/makefile cell.lib'; regexp: ********** $str=~/(.*)\s(\.\.\\(.*)\/makefile)/si ; print $2; or $str=~/(.*)\s(.*\/makefile)/si ; print $2; outputs: **************** ..\../tools/cell/makefile ..\../system-build/ali/text/makefile