> For end of the fullpath, search for '[^\/]*$' > For end of the fullpath that begins with 'm', search for 'm[^\/]*$' > 'm[^\/]*$' (why \ needs quoting? , i think is not special character in perl reg exprs) 'm[^/]*$' it will also match /bla/mbla/bla . But based on your hint i think solution is : '.*/m[^/]*$'